yonatanbitton commited on
Commit
be53140
1 Parent(s): 72fb101

Add application file

Browse files
.gitignore CHANGED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ debug_dataset.py
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py,cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # poetry
100
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
104
+ #poetry.lock
105
+
106
+ # pdm
107
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
108
+ #pdm.lock
109
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
110
+ # in version control.
111
+ # https://pdm.fming.dev/#use-with-ide
112
+ .pdm.toml
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
156
+
157
+ # PyCharm
158
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
161
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
+ #.idea/
.idea/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
.idea/inspectionProfiles/Project_Default.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
5
+ <option name="ignoredPackages">
6
+ <value>
7
+ <list size="3">
8
+ <item index="0" class="java.lang.String" itemvalue="matplotlib" />
9
+ <item index="1" class="java.lang.String" itemvalue="CLIP" />
10
+ <item index="2" class="java.lang.String" itemvalue="transformers" />
11
+ </list>
12
+ </value>
13
+ </option>
14
+ </inspection_tool>
15
+ </profile>
16
+ </component>
.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 (wmtis-explorer)" 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/wmtis-explorer.iml" filepath="$PROJECT_DIR$/.idea/wmtis-explorer.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
.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="" vcs="Git" />
5
+ </component>
6
+ </project>
.idea/wmtis-explorer.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="jdk" jdkName="Python 3.10 (wmtis-explorer)" jdkType="Python SDK" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ </component>
8
+ </module>
app.py CHANGED
@@ -15,7 +15,9 @@ CROWD_NEGATIVE_CAPTIONS = 'crowd_negative_captions'
15
  CROWD_NEGATIVE_EXPLANATIONS = 'crowd_negative_explanations'
16
  QA = 'question_answering_pairs'
17
  IMAGE_ID = 'image_id'
18
- dataset_cols = [x for x in wmtis.features.keys() if x not in [IMAGE]]
 
 
19
  enumerate_cols = [CROWD_CAPTIONS, CROWD_EXPLANATIONS, CROWD_NEGATIVE_CAPTIONS, CROWD_NEGATIVE_EXPLANATIONS]
20
  def func(index):
21
  example = wmtis[index]
@@ -25,7 +27,7 @@ def func(index):
25
 
26
  def get_instance_values(example):
27
  values = []
28
- for k in [IMAGE] + dataset_cols:
29
  if k in enumerate_cols:
30
  value = list_to_string(example[k])
31
  elif k == QA:
@@ -47,17 +49,28 @@ with demo:
47
  slider = gr.Slider(minimum=0, maximum=dataset_size, step=1, label='index')
48
  with gr.Row():
49
  index = random.choice(range(0, dataset_size))
50
- image_input = gr.Image(value=wmtis[index]["image"])
 
51
  with gr.Column():
52
- example = wmtis[index]
53
- instance_values = get_instance_values(example)
54
- text_inputs = []
55
- assert len(dataset_cols) == len(instance_values[1:]) # excluding the image
56
- for key, value in zip(dataset_cols, instance_values[1:]):
 
 
 
 
 
 
 
 
 
 
57
  label = key.capitalize().replace("_", " ")
58
  text_input_k = gr.Textbox(value=value, label=label)
59
- text_inputs.append(text_input_k)
60
 
61
- slider.change(func, inputs=[slider], outputs=[image_input] + text_inputs)
62
 
63
  demo.launch()
 
15
  CROWD_NEGATIVE_EXPLANATIONS = 'crowd_negative_explanations'
16
  QA = 'question_answering_pairs'
17
  IMAGE_ID = 'image_id'
18
+ left_side_columns = [IMAGE]
19
+ # left_side_columns = [IMAGE, DESIGNER_EXPLANATION, IMAGE_DESIGNER, IMAGE_ID]
20
+ right_side_columns = [x for x in wmtis.features.keys() if x not in left_side_columns and x not in [CROWD_NEGATIVE_EXPLANATIONS, QA]]
21
  enumerate_cols = [CROWD_CAPTIONS, CROWD_EXPLANATIONS, CROWD_NEGATIVE_CAPTIONS, CROWD_NEGATIVE_EXPLANATIONS]
22
  def func(index):
23
  example = wmtis[index]
 
27
 
28
  def get_instance_values(example):
29
  values = []
30
+ for k in left_side_columns + right_side_columns:
31
  if k in enumerate_cols:
32
  value = list_to_string(example[k])
33
  elif k == QA:
 
49
  slider = gr.Slider(minimum=0, maximum=dataset_size, step=1, label='index')
50
  with gr.Row():
51
  index = random.choice(range(0, dataset_size))
52
+ example = wmtis[index]
53
+ instance_values = get_instance_values(example)
54
  with gr.Column():
55
+ # image_input = gr.Image(value=wmtis[index]["image"])
56
+ inputs_left = []
57
+ assert len(left_side_columns) == len(
58
+ instance_values[:len(left_side_columns)]) # excluding the image & designer
59
+ for key, value in zip(left_side_columns, instance_values[:len(left_side_columns)]):
60
+ if key == IMAGE:
61
+ input_k = gr.Image(value=wmtis[index]["image"])
62
+ else:
63
+ label = key.capitalize().replace("_", " ")
64
+ input_k = gr.Textbox(value=value, label=label)
65
+ inputs_left.append(input_k)
66
+ with gr.Column():
67
+ text_inputs_right = []
68
+ assert len(right_side_columns) == len(instance_values[len(left_side_columns):]) # excluding the image & designer
69
+ for key, value in zip(right_side_columns, instance_values[len(left_side_columns):]):
70
  label = key.capitalize().replace("_", " ")
71
  text_input_k = gr.Textbox(value=value, label=label)
72
+ text_inputs_right.append(text_input_k)
73
 
74
+ slider.change(func, inputs=[slider], outputs=inputs_left + text_inputs_right)
75
 
76
  demo.launch()
requirements.txt CHANGED
@@ -0,0 +1,2 @@
 
 
 
1
+ datasets
2
+ gradio==3.0.5