marta-marta commited on
Commit
c0a3d33
·
1 Parent(s): 4ef33a4

Upload 22 files

Browse files
.gitattributes CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ 2D_Lattice.csv filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Created by .ignore support plugin (hsz.mobi)
2
+ ### Python template
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ env/
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .coverage
43
+ .coverage.*
44
+ .cache
45
+ nosetests.xml
46
+ coverage.xml
47
+ *,cover
48
+ .hypothesis/
49
+
50
+ # Translations
51
+ *.mo
52
+ *.pot
53
+
54
+ # Django stuff:
55
+ *.log
56
+ local_settings.py
57
+
58
+ # Flask stuff:
59
+ instance/
60
+ .webassets-cache
61
+
62
+ # Scrapy stuff:
63
+ .scrapy
64
+
65
+ # Sphinx documentation
66
+ docs/_build/
67
+
68
+ # PyBuilder
69
+ target/
70
+
71
+ # IPython Notebook
72
+ .ipynb_checkpoints
73
+
74
+ # pyenv
75
+ .python-version
76
+
77
+ # celery beat schedule file
78
+ celerybeat-schedule
79
+
80
+ # dotenv
81
+ .env
82
+
83
+ # virtualenv
84
+ venv/
85
+ ENV/
86
+
87
+ # Spyder project settings
88
+ .spyderproject
89
+
90
+ # Rope project settings
91
+ .ropeproject
92
+ ### VirtualEnv template
93
+ # Virtualenv
94
+ # http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
95
+ [Bb]in
96
+ [Ii]nclude
97
+ [Ll]ib
98
+ [Ll]ib64
99
+ [Ll]ocal
100
+ [Ss]cripts
101
+ pyvenv.cfg
102
+ .venv
103
+ pip-selfcheck.json
104
+
105
+ ### JetBrains template
106
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
107
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
108
+
109
+ # User-specific stuff
110
+ .idea/**/workspace.xml
111
+ .idea/**/tasks.xml
112
+ .idea/**/usage.statistics.xml
113
+ .idea/**/dictionaries
114
+ .idea/**/shelf
115
+
116
+ # AWS User-specific
117
+ .idea/**/aws.xml
118
+
119
+ # Generated files
120
+ .idea/**/contentModel.xml
121
+
122
+ # Sensitive or high-churn files
123
+ .idea/**/dataSources/
124
+ .idea/**/dataSources.ids
125
+ .idea/**/dataSources.local.xml
126
+ .idea/**/sqlDataSources.xml
127
+ .idea/**/dynamic.xml
128
+ .idea/**/uiDesigner.xml
129
+ .idea/**/dbnavigator.xml
130
+
131
+ # Gradle
132
+ .idea/**/gradle.xml
133
+ .idea/**/libraries
134
+
135
+ # Gradle and Maven with auto-import
136
+ # When using Gradle or Maven with auto-import, you should exclude module files,
137
+ # since they will be recreated, and may cause churn. Uncomment if using
138
+ # auto-import.
139
+ # .idea/artifacts
140
+ # .idea/compiler.xml
141
+ # .idea/jarRepositories.xml
142
+ # .idea/modules.xml
143
+ # .idea/*.iml
144
+ # .idea/modules
145
+ # *.iml
146
+ # *.ipr
147
+
148
+ # CMake
149
+ cmake-build-*/
150
+
151
+ # Mongo Explorer plugin
152
+ .idea/**/mongoSettings.xml
153
+
154
+ # File-based project format
155
+ *.iws
156
+
157
+ # IntelliJ
158
+ out/
159
+
160
+ # mpeltonen/sbt-idea plugin
161
+ .idea_modules/
162
+
163
+ # JIRA plugin
164
+ atlassian-ide-plugin.xml
165
+
166
+ # Cursive Clojure plugin
167
+ .idea/replstate.xml
168
+
169
+ # SonarLint plugin
170
+ .idea/sonarlint/
171
+
172
+ # Crashlytics plugin (for Android Studio and IntelliJ)
173
+ com_crashlytics_export_strings.xml
174
+ crashlytics.properties
175
+ crashlytics-build.properties
176
+ fabric.properties
177
+
178
+ # Editor-based Rest Client
179
+ .idea/httpRequests
180
+
181
+ # Android studio 3.1+ serialized cache file
182
+ .idea/caches/build_file_checksums.ser
183
+
184
+ # idea folder, uncomment if you don't need it
185
+ # .idea
.idea/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
.idea/.name ADDED
@@ -0,0 +1 @@
 
 
1
+ Dataset_Generation_Functions.py
.idea/2D_Data_Generator.iml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="PYTHON_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="inheritedJdk" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ </component>
8
+ </module>
.idea/inspectionProfiles/profiles_settings.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (Transformer_Testing)" project-jdk-type="Python SDK" />
4
+ </project>
.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/2D_Data_Generator.iml" filepath="$PROJECT_DIR$/.idea/2D_Data_Generator.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
.idea/shelf/Uncommitted_changes_before_Update_at_4_12_2023_10_18_AM_[Changes]/shelved.patch ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Index: Data_Generation/Dataset_Generation_Functions.py
2
+ IDEA additional info:
3
+ Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
4
+ <+>import numpy as np\r\nfrom Data_Generation.Piecewise_Box_Functions import basic_box_array, back_slash_array, forward_slash_array, hamburger_array, hot_dog_array\r\n\r\n# For Internal Testing\r\n# from Piecewise_Box_Functions import basic_box_array, back_slash_array, forward_slash_array, hamburger_array, hot_dog_array\r\nimport pandas as pd\r\nimport json\r\nimport matplotlib.pyplot as plt\r\nfrom json import JSONEncoder\r\n\r\n\r\n\r\n########################################################################################################################\r\n# Make the data using all the code in Shape_Generation_Functions.py\r\ndef make_boxes(image_size: int, densities: list[float]) -> list[tuple]:\r\n \"\"\"\r\n :param image_size: [int] - the pixel height and width of the generated arrays\r\n :param densities: [list[float]] - of the desired pixel values to apply to active pixels - Recommend values (0,1]\r\n :return: [list[tuple]] - [Array, Density, Thickness of each strut type]\r\n \"\"\"\r\n\r\n matrix = []\r\n\r\n # Establish the maximum thickness for each type of strut\r\n max_vert = int(np.ceil(1 / 2 * image_size) - 2)\r\n max_diag = int(image_size - 3)\r\n max_basic = int(np.ceil(1 / 2 * image_size) - 1)\r\n\r\n # Adds different density values\r\n for i in range(len(densities)):\r\n for j in range(1, max_basic): # basic box loop, always want a border\r\n basic_box_thickness = j\r\n array_1 = basic_box_array(image_size, basic_box_thickness)\r\n if np.unique([array_1]).all() > 0: # Checks if there is a solid figure\r\n break\r\n\r\n for k in range(0, max_vert):\r\n hamburger_box_thickness = k\r\n array_2 = hamburger_array(image_size, hamburger_box_thickness) + array_1\r\n array_2 = np.array(array_2 > 0, dtype=int) # Keep all values 0/1\r\n if np.unique([array_2]).all() > 0:\r\n break\r\n\r\n for l in range(0, max_vert):\r\n hot_dog_box_thickness = l\r\n array_3 = hot_dog_array(image_size, hot_dog_box_thickness) + array_2\r\n array_3 = np.array(array_3 > 0, dtype=int)\r\n if np.unique([array_3]).all() > 0:\r\n break\r\n\r\n for m in range(0, max_diag):\r\n forward_slash_box_thickness = m\r\n array_4 = forward_slash_array(image_size, forward_slash_box_thickness) + array_3\r\n array_4 = np.array(array_4 > 0, dtype=int)\r\n if np.unique([array_4]).all() > 0:\r\n break\r\n\r\n for n in range(0, max_diag):\r\n back_slash_box_thickness = n\r\n array_5 = back_slash_array(image_size, back_slash_box_thickness) + array_4\r\n array_5 = np.array(array_5 > 0, dtype=int)\r\n if np.unique([array_5]).all() > 0:\r\n break\r\n the_tuple = (array_5*densities[i], densities[i], basic_box_thickness,\r\n forward_slash_box_thickness, back_slash_box_thickness,\r\n hot_dog_box_thickness, hamburger_box_thickness)\r\n matrix.append(the_tuple)\r\n\r\n return matrix\r\n\r\n\r\n########################################################################################################################\r\n# How to read the files\r\n'''\r\ndf = pd.read_csv('2D_Lattice.csv')\r\nprint(np.shape(df))\r\nrow = 1\r\nbox = df.iloc[row, 1]\r\narray = np.array(json.loads(box))\r\nplt.imshow(array, vmin=0, vmax=1)\r\nplt.show()\r\n'''\r\n
5
+ Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
6
+ <+>UTF-8
7
+ ===================================================================
8
+ diff --git a/Data_Generation/Dataset_Generation_Functions.py b/Data_Generation/Dataset_Generation_Functions.py
9
+ --- a/Data_Generation/Dataset_Generation_Functions.py (revision 73d009aa1257fa61975a6aaf139763f239908c6a)
10
+ +++ b/Data_Generation/Dataset_Generation_Functions.py (date 1681258622233)
11
+ @@ -9,14 +9,14 @@
12
+ from json import JSONEncoder
13
+
14
+
15
+ -
16
+ ########################################################################################################################
17
+ # Make the data using all the code in Shape_Generation_Functions.py
18
+ def make_boxes(image_size: int, densities: list[float]) -> list[tuple]:
19
+ """
20
+ :param image_size: [int] - the pixel height and width of the generated arrays
21
+ :param densities: [list[float]] - of the desired pixel values to apply to active pixels - Recommend values (0,1]
22
+ - :return: [list[tuple]] - [Array, Density, Thickness of each strut type]
23
+ + :return: [list[tuple]] - [Array, Density, Thickness of each strut type] this is all the defining information for
24
+ + all the generated data.
25
+ """
26
+
27
+ matrix = []
.idea/shelf/Uncommitted_changes_before_Update_at_4_12_2023_10_18_AM__Changes_.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ <changelist name="Uncommitted_changes_before_Update_at_4_12_2023_10_18_AM_[Changes]" date="1681309102915" recycled="true" deleted="true">
2
+ <option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_4_12_2023_10_18_AM_[Changes]/shelved.patch" />
3
+ <option name="DESCRIPTION" value="Uncommitted changes before Update at 4/12/2023 10:18 AM [Changes]" />
4
+ <binary>
5
+ <option name="BEFORE_PATH" value="Data_Plotting/2D_Lattice.csv" />
6
+ <option name="AFTER_PATH" />
7
+ <option name="SHELVED_PATH" />
8
+ </binary>
9
+ </changelist>
.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
.idea/workspace.xml ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ChangeListManager">
4
+ <list default="true" id="edb75e09-4781-41cb-bdaf-0c543336cafb" name="Changes" comment="Finalizing notes and type hints">
5
+ <change beforePath="$PROJECT_DIR$/.idea/.name" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.name" afterDir="false" />
6
+ </list>
7
+ <option name="SHOW_DIALOG" value="false" />
8
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
9
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
10
+ <option name="LAST_RESOLUTION" value="IGNORE" />
11
+ </component>
12
+ <component name="FileTemplateManagerImpl">
13
+ <option name="RECENT_TEMPLATES">
14
+ <list>
15
+ <option value="Python Script" />
16
+ </list>
17
+ </option>
18
+ </component>
19
+ <component name="Git.Settings">
20
+ <option name="PUSH_AUTO_UPDATE" value="true" />
21
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
22
+ </component>
23
+ <component name="MarkdownSettingsMigration">
24
+ <option name="stateVersion" value="1" />
25
+ </component>
26
+ <component name="ProjectId" id="2Mn8XK1cdGiSsV9UEBWbPOPJgB7" />
27
+ <component name="ProjectViewState">
28
+ <option name="hideEmptyMiddlePackages" value="true" />
29
+ <option name="showLibraryContents" value="true" />
30
+ </component>
31
+ <component name="PropertiesComponent">{
32
+ &quot;keyToString&quot;: {
33
+ &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
34
+ &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;
35
+ }
36
+ }</component>
37
+ <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
38
+ <component name="TaskManager">
39
+ <task active="true" id="Default" summary="Default task">
40
+ <changelist id="edb75e09-4781-41cb-bdaf-0c543336cafb" name="Changes" comment="" />
41
+ <created>1678392024806</created>
42
+ <option name="number" value="Default" />
43
+ <option name="presentableId" value="Default" />
44
+ <updated>1678392024806</updated>
45
+ </task>
46
+ <task id="LOCAL-00001" summary="Added TSNE Plot">
47
+ <created>1678393478950</created>
48
+ <option name="number" value="00001" />
49
+ <option name="presentableId" value="LOCAL-00001" />
50
+ <option name="project" value="LOCAL" />
51
+ <updated>1678393478950</updated>
52
+ </task>
53
+ <task id="LOCAL-00002" summary="Added TSNE Plot">
54
+ <created>1678393551376</created>
55
+ <option name="number" value="00002" />
56
+ <option name="presentableId" value="LOCAL-00002" />
57
+ <option name="project" value="LOCAL" />
58
+ <updated>1678393551376</updated>
59
+ </task>
60
+ <task id="LOCAL-00003" summary="Need new libs to be considered in the app">
61
+ <created>1678393979280</created>
62
+ <option name="number" value="00003" />
63
+ <option name="presentableId" value="LOCAL-00003" />
64
+ <option name="project" value="LOCAL" />
65
+ <updated>1678393979280</updated>
66
+ </task>
67
+ <task id="LOCAL-00004" summary="Need new libs to be considered in the app">
68
+ <created>1678394247061</created>
69
+ <option name="number" value="00004" />
70
+ <option name="presentableId" value="LOCAL-00004" />
71
+ <option name="project" value="LOCAL" />
72
+ <updated>1678394247061</updated>
73
+ </task>
74
+ <task id="LOCAL-00005" summary="Need new libs to be considered in the app">
75
+ <created>1678394457121</created>
76
+ <option name="number" value="00005" />
77
+ <option name="presentableId" value="LOCAL-00005" />
78
+ <option name="project" value="LOCAL" />
79
+ <updated>1678394457121</updated>
80
+ </task>
81
+ <task id="LOCAL-00006" summary="Need new libs to be considered in the app">
82
+ <created>1678552905009</created>
83
+ <option name="number" value="00006" />
84
+ <option name="presentableId" value="LOCAL-00006" />
85
+ <option name="project" value="LOCAL" />
86
+ <updated>1678552905009</updated>
87
+ </task>
88
+ <task id="LOCAL-00007" summary="Updating T-SNE Plot">
89
+ <created>1678715116034</created>
90
+ <option name="number" value="00007" />
91
+ <option name="presentableId" value="LOCAL-00007" />
92
+ <option name="project" value="LOCAL" />
93
+ <updated>1678715116034</updated>
94
+ </task>
95
+ <task id="LOCAL-00008" summary="Updating T-SNE Plot">
96
+ <created>1678715168773</created>
97
+ <option name="number" value="00008" />
98
+ <option name="presentableId" value="LOCAL-00008" />
99
+ <option name="project" value="LOCAL" />
100
+ <updated>1678715168773</updated>
101
+ </task>
102
+ <task id="LOCAL-00009" summary="Updating T-SNE Plot">
103
+ <created>1678715205966</created>
104
+ <option name="number" value="00009" />
105
+ <option name="presentableId" value="LOCAL-00009" />
106
+ <option name="project" value="LOCAL" />
107
+ <updated>1678715205966</updated>
108
+ </task>
109
+ <task id="LOCAL-00010" summary="Updating T-SNE Plot">
110
+ <created>1678715414287</created>
111
+ <option name="number" value="00010" />
112
+ <option name="presentableId" value="LOCAL-00010" />
113
+ <option name="project" value="LOCAL" />
114
+ <updated>1678715414287</updated>
115
+ </task>
116
+ <task id="LOCAL-00011" summary="Adding type hints to the functions in these scripts">
117
+ <created>1681243653443</created>
118
+ <option name="number" value="00011" />
119
+ <option name="presentableId" value="LOCAL-00011" />
120
+ <option name="project" value="LOCAL" />
121
+ <updated>1681243653443</updated>
122
+ </task>
123
+ <task id="LOCAL-00012" summary="Adding type hints to the functions in these scripts">
124
+ <created>1681309005767</created>
125
+ <option name="number" value="00012" />
126
+ <option name="presentableId" value="LOCAL-00012" />
127
+ <option name="project" value="LOCAL" />
128
+ <updated>1681309005767</updated>
129
+ </task>
130
+ <task id="LOCAL-00013" summary="Adding type hints to the functions in these scripts">
131
+ <created>1681309096299</created>
132
+ <option name="number" value="00013" />
133
+ <option name="presentableId" value="LOCAL-00013" />
134
+ <option name="project" value="LOCAL" />
135
+ <updated>1681309096299</updated>
136
+ </task>
137
+ <task id="LOCAL-00014" summary="Addressing type hint error">
138
+ <created>1681309886030</created>
139
+ <option name="number" value="00014" />
140
+ <option name="presentableId" value="LOCAL-00014" />
141
+ <option name="project" value="LOCAL" />
142
+ <updated>1681309886030</updated>
143
+ </task>
144
+ <task id="LOCAL-00015" summary="Addressing type hint error">
145
+ <created>1681341437941</created>
146
+ <option name="number" value="00015" />
147
+ <option name="presentableId" value="LOCAL-00015" />
148
+ <option name="project" value="LOCAL" />
149
+ <updated>1681341437941</updated>
150
+ </task>
151
+ <task id="LOCAL-00016" summary="Finalizing notes and type hints">
152
+ <created>1681342765997</created>
153
+ <option name="number" value="00016" />
154
+ <option name="presentableId" value="LOCAL-00016" />
155
+ <option name="project" value="LOCAL" />
156
+ <updated>1681342765997</updated>
157
+ </task>
158
+ <option name="localTasksCounter" value="17" />
159
+ <servers />
160
+ </component>
161
+ <component name="Vcs.Log.Tabs.Properties">
162
+ <option name="TAB_STATES">
163
+ <map>
164
+ <entry key="MAIN">
165
+ <value>
166
+ <State />
167
+ </value>
168
+ </entry>
169
+ </map>
170
+ </option>
171
+ </component>
172
+ <component name="VcsManagerConfiguration">
173
+ <MESSAGE value="Added TSNE Plot" />
174
+ <MESSAGE value="Need new libs to be considered in the app" />
175
+ <MESSAGE value="Updating T-SNE Plot" />
176
+ <MESSAGE value="Adding type hints to the functions in these scripts" />
177
+ <MESSAGE value="Addressing type hint error" />
178
+ <MESSAGE value="Finalizing notes and type hints" />
179
+ <option name="LAST_COMMIT_MESSAGE" value="Finalizing notes and type hints" />
180
+ </component>
181
+ </project>
Data_Generation/Dataset_Generation_Functions.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ from Data_Generation.Piecewise_Box_Functions import basic_box_array, back_slash_array, forward_slash_array, hamburger_array, hot_dog_array
3
+
4
+ # For Internal Testing
5
+ # from Piecewise_Box_Functions import basic_box_array, back_slash_array, forward_slash_array, hamburger_array, hot_dog_array
6
+ import pandas as pd
7
+ import json
8
+ import matplotlib.pyplot as plt
9
+ from json import JSONEncoder
10
+
11
+
12
+ ########################################################################################################################
13
+ # Make the data using all the code in Shape_Generation_Functions.py
14
+ def make_boxes(image_size: int, densities: list) -> list:
15
+ """
16
+ :param image_size: [int] - the pixel height and width of the generated arrays
17
+ :param densities: [list[float]] - of the desired pixel values to apply to active pixels - Recommend values (0,1]
18
+ :return: list[tuple] - [Array, Density, Thickness of each strut type] this is all the defining information for
19
+ all the generated data.
20
+ """
21
+
22
+ matrix = []
23
+
24
+ # Establish the maximum thickness for each type of strut
25
+ max_vert = int(np.ceil(1 / 2 * image_size) - 2)
26
+ max_diag = int(image_size - 3)
27
+ max_basic = int(np.ceil(1 / 2 * image_size) - 1)
28
+
29
+ # Adds different density values
30
+ for i in range(len(densities)):
31
+ for j in range(1, max_basic): # basic box loop, always want a border
32
+ basic_box_thickness = j
33
+ array_1 = basic_box_array(image_size, basic_box_thickness)
34
+ if np.unique([array_1]).all() > 0: # Checks if there is a solid figure
35
+ break
36
+
37
+ for k in range(0, max_vert):
38
+ hamburger_box_thickness = k
39
+ array_2 = hamburger_array(image_size, hamburger_box_thickness) + array_1
40
+ array_2 = np.array(array_2 > 0, dtype=int) # Keep all values 0/1
41
+ if np.unique([array_2]).all() > 0:
42
+ break
43
+
44
+ for l in range(0, max_vert):
45
+ hot_dog_box_thickness = l
46
+ array_3 = hot_dog_array(image_size, hot_dog_box_thickness) + array_2
47
+ array_3 = np.array(array_3 > 0, dtype=int)
48
+ if np.unique([array_3]).all() > 0:
49
+ break
50
+
51
+ for m in range(0, max_diag):
52
+ forward_slash_box_thickness = m
53
+ array_4 = forward_slash_array(image_size, forward_slash_box_thickness) + array_3
54
+ array_4 = np.array(array_4 > 0, dtype=int)
55
+ if np.unique([array_4]).all() > 0:
56
+ break
57
+
58
+ for n in range(0, max_diag):
59
+ back_slash_box_thickness = n
60
+ array_5 = back_slash_array(image_size, back_slash_box_thickness) + array_4
61
+ array_5 = np.array(array_5 > 0, dtype=int)
62
+ if np.unique([array_5]).all() > 0:
63
+ break
64
+ the_tuple = (array_5*densities[i], densities[i], basic_box_thickness,
65
+ forward_slash_box_thickness, back_slash_box_thickness,
66
+ hot_dog_box_thickness, hamburger_box_thickness)
67
+ matrix.append(the_tuple)
68
+
69
+ return matrix
70
+
71
+
72
+ ########################################################################################################################
73
+ # How to read the files
74
+ '''
75
+ df = pd.read_csv('2D_Lattice.csv')
76
+ print(np.shape(df))
77
+ row = 1
78
+ box = df.iloc[row, 1]
79
+ array = np.array(json.loads(box))
80
+ plt.imshow(array, vmin=0, vmax=1)
81
+ plt.show()
82
+ '''
Data_Generation/Piecewise_Box_Functions.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ from scipy import signal
3
+
4
+
5
+ def basic_box_array(image_size: int, thickness: int) -> np.ndarray:
6
+ """
7
+ :param image_size: [int] - the size of the image that will be produced
8
+ :param thickness: [int] - the number of pixels to be activated surrounding the base shape
9
+ :return: [ndarray] - the output is a unit cell with outer pixels activated based on the desired thickness.
10
+ The activated pixels are 1 (white) and the deactivated pixels are 0 (black)
11
+ """
12
+ A = np.ones((int(image_size), int(image_size))) # Initializes A matrix with 0 values
13
+ A[1:-1, 1:-1] = 0 # replaces all internal rows/columns with 0's
14
+ A = add_thickness(A, thickness)
15
+ return A
16
+
17
+
18
+ def back_slash_array(image_size: int, thickness: int) -> np.ndarray:
19
+ """
20
+ :param image_size: [int] - the size of the image that will be produced
21
+ :param thickness: [int] - the number of pixels to be activated surrounding the base shape
22
+ :return: [ndarray] - the output is a unit cell with pixels activated along the downward diagonal based
23
+ on the desired thickness. The activated pixels are 1 (white) and the deactivated pixels are 0 (black)
24
+ """
25
+ A = np.zeros((int(image_size), int(image_size))) # Initializes A matrix with 0 values
26
+ np.fill_diagonal(A, 1) # fills the diagonal with 1 values
27
+ A = add_thickness(A, thickness)
28
+ return A
29
+
30
+
31
+ def forward_slash_array(image_size: int, thickness: int) -> np.ndarray:
32
+ """
33
+ :param image_size: [int] - the size of the image that will be produced
34
+ :param thickness: [int] - the number of pixels to be activated surrounding the base shape
35
+ :return: [ndarray] - the output is a unit cell with pixels activated along the upward diagonal based on the desired
36
+ thickness. The activated pixels are 1 (white) and the deactivated pixels are 0 (black)
37
+ """
38
+ A = np.zeros((int(image_size), int(image_size))) # Initializes A matrix with 0 values
39
+ np.fill_diagonal(np.fliplr(A), 1) # Flips the array to then fill the diagonal the opposite direction
40
+ A = add_thickness(A, thickness)
41
+ return A
42
+
43
+
44
+ def hot_dog_array(image_size: int, thickness: int) -> np.ndarray:
45
+ """
46
+ :param image_size: [int] - the size of the image that will be produced
47
+ :param thickness: [int] - the number of pixels to be activated surrounding the base shape
48
+ :return: [ndarray] - the output is a unit cell with outer pixel activated from the vertical center based on the
49
+ desired thickness. The activated pixels are 1 (white) and the deactivated pixels are 0 (black)
50
+ """
51
+ # Places pixels down the vertical axis to split the box
52
+ A = np.zeros((int(image_size), int(image_size))) # Initializes A matrix with 0 values
53
+ A[:, np.floor((image_size - 1) / 2).astype(int)] = 1 # accounts for even and odd values of image_size
54
+ A[:, np.ceil((image_size - 1) / 2).astype(int)] = 1
55
+ A = add_thickness(A, thickness)
56
+ return A
57
+
58
+
59
+ def hamburger_array(image_size: int, thickness: int) -> np.ndarray:
60
+ """
61
+ :param image_size: [int] - the size of the image that will be produced
62
+ :param thickness: [int] - the number of pixels to be activated surrounding the base shape
63
+ :return: [ndarray] - the output is a unit cell with outer pixel activated from the horizontal center based on the
64
+ desired thickness. The activated pixels are 1 (white) and the deactivated pixels are 0 (black)
65
+ """
66
+ # Places pixels across the horizontal axis to split the box
67
+ A = np.zeros((int(image_size), int(image_size))) # Initializes A matrix with 0 values
68
+ A[np.floor((image_size - 1) / 2).astype(int), :] = 1 # accounts for even and odd values of image_size
69
+ A[np.ceil((image_size - 1) / 2).astype(int), :] = 1
70
+ A = add_thickness(A, thickness)
71
+ return A
72
+
73
+
74
+ ########################################################################################################################
75
+ # The function to add thickness to struts in an array
76
+ def add_thickness(array_original, thickness: int) -> np.ndarray:
77
+ """
78
+ :param array_original: [ndarray] - an array with thickness 1 of any shape type
79
+ :param thickness: [int] - the number of pixels to be activated surrounding the base shape
80
+ :return: [ndarray] - the output is a unit cell that has been convolved to expand the number of pixels activated
81
+ based on the desired thickness. The activated pixels are 1 (white) and the deactivated pixels are 0 (black)
82
+ """
83
+ A = array_original
84
+ if thickness == 0: # want an array of all 0's for thickness = 0
85
+ A[A > 0] = 0
86
+ else:
87
+ filter_size = 2*thickness - 1 # the size of the filter needs to extend far enough to reach the base shape
88
+ filter = np.zeros((filter_size, filter_size))
89
+ filter[np.floor((filter_size - 1) / 2).astype(int), :] = filter[:, np.floor((filter_size - 1) / 2).astype(int)] =1
90
+ filter[np.ceil((filter_size - 1) / 2).astype(int), :] = filter[:, np.ceil((filter_size - 1) / 2).astype(int)] = 1
91
+ # The filter is made into a '+' shape using these functions
92
+ convolution = signal.convolve2d(A, filter, mode='same')
93
+ A = np.where(convolution <= 1, convolution, 1)
94
+ return A
95
+
96
+
97
+ # The function to efficiently combine arrays in a list
98
+ def combine_arrays(arrays):
99
+ output_array = np.sum(arrays, axis=0) # Add the list of arrays
100
+ output_array = np.array(output_array > 0, dtype=int) # Convert all values in array to 1
101
+ return output_array
Data_Generation/__pycache__/Dataset_Generation_Functions.cpython-310.pyc ADDED
Binary file (1.83 kB). View file
 
Data_Generation/__pycache__/Piecewise_Box_Functions.cpython-310.pyc ADDED
Binary file (2.07 kB). View file
 
Data_Plotting/Plot_TSNE.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from sklearn.manifold import TSNE
2
+ import matplotlib.pyplot as plt
3
+ import numpy as np
4
+
5
+
6
+ # Latent Feature Cluster for Training Data using T-SNE
7
+ def TSNE_reduction(latent_points: np.ndarray, perplexity=30, learning_rate=20):
8
+ """
9
+ :param latent_points: [ndarray] - an array of arrays that define the points of multiple objects in the latent space
10
+ :param perplexity: [int] - default perplexity = 30 " Perplexity balances the attention t-SNE gives to local and global aspects of the data. It is roughly a guess of the number of close neighbors each point has... a denser dataset ... requires higher perplexity value" Recommended: Perplexity(5-50)
11
+ :param learning_rate: [int] - default learning rate = 200 "If the learning rate is too high, the data may look like a ‘ball’ with any point approximately equidistant from its nearest neighbours. If the learning rate is too low, most points may look compressed in a dense cloud with few outliers." Recommended: learning_rate(10-1000)
12
+ :return: [tuple] - the output is the x and y coordinates for the reduced latent space, a title, and a TSNE embedding
13
+ """
14
+ model = TSNE(n_components=2, random_state=0, perplexity=perplexity,
15
+ learning_rate=learning_rate)
16
+ # the number of components = dimension of the embedded space
17
+
18
+ embedding = model
19
+
20
+ tsne_data = model.fit_transform(latent_points)
21
+ # When there are more data points, only use a couple of hundred points so TSNE doesn't take too long
22
+ x = tsne_data[:, 0]
23
+ y = tsne_data[:, 1]
24
+ title = ("T-SNE of Data")
25
+ return x, y, title, embedding
26
+
27
+
28
+ def plot_dimensionality_reduction(x: list, y: list, label_set: list, title: str):
29
+ """
30
+ :param x: [list] - the first set of coordinates for each latent point
31
+ :param y: [list] - the second set of coordinates for each latent point
32
+ :param label_set: [list] - a set of values that define the color of each point based on an additional quantitative attribute.
33
+ :return: matplotlib figure - the output is a matplotlib figure that displays all the points in a 2-dimensional latent space, based on the labels provided.
34
+ """
35
+ plt.title(title)
36
+ # Color points based on a continuous label
37
+ if label_set[0].dtype == float:
38
+ plt.scatter(x, y, c=label_set)
39
+ cbar = plt.colorbar()
40
+ cbar.set_label('Average Density', fontsize=12)
41
+ print("using scatter")
42
+
43
+ # Color points based on a discrete label
44
+ else:
45
+ for label in set(label_set):
46
+ cond = np.where(np.array(label_set) == str(label))
47
+ plt.plot(x[cond], y[cond], marker='o', linestyle='none', label=label)
48
+
49
+ plt.legend(numpoints=1)
50
+ plt.xlabel("Dimension 1")
51
+ plt.ylabel("Dimension 2")
52
+ ########################################################################################################################
53
+ """
54
+ # Use for personal plotting
55
+
56
+ import pandas as pd
57
+ import json
58
+
59
+ df = pd.read_csv('2D_Lattice.csv')
60
+ # row = 0
61
+ # box = df.iloc[row,1]
62
+ # array = np.array(json.loads(box))
63
+
64
+ # Select a subset of the data to use
65
+ number_samples = 10000
66
+ perplexity = 300
67
+
68
+ random_samples = sorted(np.random.randint(0,len(df), number_samples)) # Generates ordered samples
69
+
70
+ df = df.iloc[random_samples]
71
+
72
+ print(df)
73
+ print(np.shape(df))
74
+
75
+
76
+ # For plotting CSV data
77
+ # define a function to flatten a box
78
+ def flatten_box(box_str):
79
+ box = json.loads(box_str)
80
+ return np.array(box).flatten()
81
+
82
+
83
+ # apply the flatten_box function to each row of the dataframe and create a list of flattened arrays
84
+ flattened_arrays = df['Array'].apply(flatten_box).tolist()
85
+ avg_density = np.sum(flattened_arrays, axis=1)/(len(flattened_arrays[0]))
86
+
87
+ x, y, title, embedding = TSNE_reduction(flattened_arrays, perplexity=perplexity)
88
+ plot_dimensionality_reduction(x, y, avg_density, title)
89
+ plt.title(title)
90
+ plt.savefig('TSNE_Partial_Factorial_Perplexity_' + str(perplexity) + "_Data_Samples_" + str(number_samples))
91
+
92
+ """
93
+
Data_Plotting/TSNE_Full_Factorial.png ADDED
Data_Plotting/TSNE_Partial_Factorial_Perplexity_300_Data_Samples_10000.png ADDED
Data_Plotting/__pycache__/Plot_TSNE.cpython-310.pyc ADDED
Binary file (1.26 kB). View file
 
README.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: AddLat2D
3
+ emoji: 😻
4
+ colorFrom: purple
5
+ colorTo: blue
6
+ sdk: streamlit
7
+ sdk_version: 1.17.0
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ Use the following code to load items in the 2D_Lattice.csv file
13
+ import pandas as pd
14
+ import json
15
+ df = pd.read_csv('2D_Lattice.csv')
16
+ row = 0
17
+ box = df.iloc[row,1]
18
+ array = np.array(json.loads(box))
19
+
20
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ matplotlib==3.5.2
2
+ numpy==1.21.5
3
+ pandas==1.4.4
4
+ scikit_learn==1.2.2
5
+ scipy==1.9.1
6
+ streamlit==1.18.1