Spaces:
Runtime error
Runtime error
Commit
·
3a5e47f
1
Parent(s):
af17c2f
formatting
Browse files
app.py
CHANGED
@@ -130,13 +130,15 @@ def predict_subset(model_id, token):
|
|
130 |
|
131 |
|
132 |
with gr.Blocks() as demo:
|
133 |
-
gr.Markdown(
|
|
|
134 |
This [Gradio](https://gradio.app/) [Space](https://huggingface.co/spaces/launch) allows you to explore an image dataset exported from ARCH: Archive Research Compute Hub from the [Internet Archive](https://archive.org/).
|
135 |
Each tab allows you to explore the dataset in a slightly different way by making use of Machine Learning models and tools from the Hugging Face ecosystem.
|
136 |
-
"""
|
|
|
137 |
with gr.Tab("Random Image Gallery"):
|
138 |
gr.Markdown(
|
139 |
-
|
140 |
This tab allows you to explore images in your ARCH collection. You can refresh the images by clicking the refresh button.
|
141 |
**Please note** not all images will be displayed as some images may not available via the original URLS anymore."""
|
142 |
)
|
@@ -145,7 +147,7 @@ with gr.Blocks() as demo:
|
|
145 |
button.click(return_random_sample, [], [gallery])
|
146 |
with gr.Tab("Image Search"):
|
147 |
gr.Markdown(
|
148 |
-
|
149 |
You can search for images by entering a search term and clicking the search button.
|
150 |
You can also change the number of images to be returned.
|
151 |
This model uses the [clip-ViT-B-16](https://huggingface.co/sentence-transformers/clip-ViT-B-16) model to embed your images and search term"""
|
@@ -162,7 +164,7 @@ with gr.Blocks() as demo:
|
|
162 |
|
163 |
with gr.Tab("Image Classification Model Tester"):
|
164 |
gr.Markdown(
|
165 |
-
|
166 |
You can use this to test out [image classification models](https://huggingface.co/models?pipeline_tag=image-classification) on the Hugging Face Hub:
|
167 |
- To use this tab you will need to have a Hugging Face account and a valid token.
|
168 |
- You can get a token from your [Hugging Face account page](https://huggingface.co/settings/token).
|
@@ -173,21 +175,25 @@ with gr.Blocks() as demo:
|
|
173 |
)
|
174 |
token = gr.Textbox(label="token", type="password")
|
175 |
|
176 |
-
model_id = gr.Textbox(
|
|
|
|
|
177 |
button = gr.Button("predict")
|
178 |
gr.Markdown("## Results")
|
179 |
plot = gr.BarPlot(x="labels", y="freqs", width=600, height=400, vertical=False)
|
180 |
gallery = gr.Gallery()
|
181 |
button.click(predict_subset, [model_id, token], [gallery, plot])
|
182 |
with gr.Tab("Export to Label Studio format"):
|
183 |
-
gr.Markdown(
|
|
|
184 |
## Export to Label Studio format
|
185 |
<img align=left src="https://warehouse-camo.ingress.cmh1.psfhosted.org/ba8de1e22c982bbfc28201dcc953ca15e92a399c/68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f686561727465786c6162732f6c6162656c2d73747564696f2f6d61737465722f696d616765732f6c735f6769746875625f6865616465722e706e67">
|
186 |
This will export the current dataset to a csv file which can be imported into [Label Studio](https://labelstud.io/). You can then import this into Label Studio to label your images by hand.
|
187 |
-
You can run Label Studio using Hugging Face Spaces using this [Spaces template](https://huggingface.co/new-space?template=LabelStudio/LabelStudio)"""
|
|
|
188 |
|
189 |
dataset2 = copy.deepcopy(dataset)
|
190 |
-
dataset2 = dataset2.remove_columns(
|
191 |
dataset2 = dataset2.rename_column("url", "image")
|
192 |
csv = dataset2.to_csv("label_studio.csv")
|
193 |
csv_file = gr.File("label_studio.csv")
|
|
|
130 |
|
131 |
|
132 |
with gr.Blocks() as demo:
|
133 |
+
gr.Markdown(
|
134 |
+
"""# ARCH Image Dataset Explorer
|
135 |
This [Gradio](https://gradio.app/) [Space](https://huggingface.co/spaces/launch) allows you to explore an image dataset exported from ARCH: Archive Research Compute Hub from the [Internet Archive](https://archive.org/).
|
136 |
Each tab allows you to explore the dataset in a slightly different way by making use of Machine Learning models and tools from the Hugging Face ecosystem.
|
137 |
+
"""
|
138 |
+
)
|
139 |
with gr.Tab("Random Image Gallery"):
|
140 |
gr.Markdown(
|
141 |
+
"""## Random image gallery
|
142 |
This tab allows you to explore images in your ARCH collection. You can refresh the images by clicking the refresh button.
|
143 |
**Please note** not all images will be displayed as some images may not available via the original URLS anymore."""
|
144 |
)
|
|
|
147 |
button.click(return_random_sample, [], [gallery])
|
148 |
with gr.Tab("Image Search"):
|
149 |
gr.Markdown(
|
150 |
+
"""## Image search
|
151 |
You can search for images by entering a search term and clicking the search button.
|
152 |
You can also change the number of images to be returned.
|
153 |
This model uses the [clip-ViT-B-16](https://huggingface.co/sentence-transformers/clip-ViT-B-16) model to embed your images and search term"""
|
|
|
164 |
|
165 |
with gr.Tab("Image Classification Model Tester"):
|
166 |
gr.Markdown(
|
167 |
+
"""## Image classification model tester
|
168 |
You can use this to test out [image classification models](https://huggingface.co/models?pipeline_tag=image-classification) on the Hugging Face Hub:
|
169 |
- To use this tab you will need to have a Hugging Face account and a valid token.
|
170 |
- You can get a token from your [Hugging Face account page](https://huggingface.co/settings/token).
|
|
|
175 |
)
|
176 |
token = gr.Textbox(label="token", type="password")
|
177 |
|
178 |
+
model_id = gr.Textbox(
|
179 |
+
label="model_id", value="davanstrien/autotrain-wikiart-sample2-42615108993"
|
180 |
+
)
|
181 |
button = gr.Button("predict")
|
182 |
gr.Markdown("## Results")
|
183 |
plot = gr.BarPlot(x="labels", y="freqs", width=600, height=400, vertical=False)
|
184 |
gallery = gr.Gallery()
|
185 |
button.click(predict_subset, [model_id, token], [gallery, plot])
|
186 |
with gr.Tab("Export to Label Studio format"):
|
187 |
+
gr.Markdown(
|
188 |
+
"""
|
189 |
## Export to Label Studio format
|
190 |
<img align=left src="https://warehouse-camo.ingress.cmh1.psfhosted.org/ba8de1e22c982bbfc28201dcc953ca15e92a399c/68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f686561727465786c6162732f6c6162656c2d73747564696f2f6d61737465722f696d616765732f6c735f6769746875625f6865616465722e706e67">
|
191 |
This will export the current dataset to a csv file which can be imported into [Label Studio](https://labelstud.io/). You can then import this into Label Studio to label your images by hand.
|
192 |
+
You can run Label Studio using Hugging Face Spaces using this [Spaces template](https://huggingface.co/new-space?template=LabelStudio/LabelStudio)"""
|
193 |
+
)
|
194 |
|
195 |
dataset2 = copy.deepcopy(dataset)
|
196 |
+
dataset2 = dataset2.remove_columns("image")
|
197 |
dataset2 = dataset2.rename_column("url", "image")
|
198 |
csv = dataset2.to_csv("label_studio.csv")
|
199 |
csv_file = gr.File("label_studio.csv")
|