Spaces:
Runtime error
Runtime error
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
from pathlib import Path
|
3 |
from PIL import Image, ExifTags
|
@@ -10,6 +11,7 @@ from huggingface_hub import HfApi
|
|
10 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
11 |
logger = logging.getLogger(__name__)
|
12 |
|
|
|
13 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
14 |
HF_USERNAME = "latterworks"
|
15 |
DATASET_NAME = "geo-metadata"
|
@@ -130,16 +132,16 @@ def process_images(image_files):
|
|
130 |
"images": [entry.get("file_name") for entry in metadata_list],
|
131 |
"metadata": metadata_list
|
132 |
})
|
133 |
-
dataset.push_to_hub(f"
|
134 |
api = HfApi()
|
135 |
api.upload_file(
|
136 |
path_or_fileobj=output_file,
|
137 |
path_in_repo="metadata.jsonl",
|
138 |
-
repo_id=f"
|
139 |
repo_type="dataset",
|
140 |
token=HF_TOKEN
|
141 |
)
|
142 |
-
return f"Processed {len(metadata_list)} images. Metadata saved to {output_file} and uploaded to
|
143 |
return f"Processed {len(metadata_list)} images. Metadata saved to {output_file}", output_file
|
144 |
|
145 |
demo = gr.Interface(
|
@@ -147,7 +149,7 @@ demo = gr.Interface(
|
|
147 |
inputs=gr.Files(label="Upload Images", file_types=["image"]),
|
148 |
outputs=[gr.Textbox(label="Status"), gr.File(label="Download Metadata")],
|
149 |
title="Geo-Metadata Extractor",
|
150 |
-
description="Upload images to extract metadata (including GPS) and upload to Hugging Face Hub."
|
151 |
)
|
152 |
|
153 |
if __name__ == "__main__":
|
|
|
1 |
+
|
2 |
import gradio as gr
|
3 |
from pathlib import Path
|
4 |
from PIL import Image, ExifTags
|
|
|
11 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
|
12 |
logger = logging.getLogger(__name__)
|
13 |
|
14 |
+
# Token should be set as a secret in the Space settings
|
15 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
16 |
HF_USERNAME = "latterworks"
|
17 |
DATASET_NAME = "geo-metadata"
|
|
|
132 |
"images": [entry.get("file_name") for entry in metadata_list],
|
133 |
"metadata": metadata_list
|
134 |
})
|
135 |
+
dataset.push_to_hub(f"latterworks/geo-metadata", token=HF_TOKEN)
|
136 |
api = HfApi()
|
137 |
api.upload_file(
|
138 |
path_or_fileobj=output_file,
|
139 |
path_in_repo="metadata.jsonl",
|
140 |
+
repo_id=f"latterworks/geo-metadata",
|
141 |
repo_type="dataset",
|
142 |
token=HF_TOKEN
|
143 |
)
|
144 |
+
return f"Processed {len(metadata_list)} images. Metadata saved to {output_file} and uploaded to latterworks/geo-metadata", output_file
|
145 |
return f"Processed {len(metadata_list)} images. Metadata saved to {output_file}", output_file
|
146 |
|
147 |
demo = gr.Interface(
|
|
|
149 |
inputs=gr.Files(label="Upload Images", file_types=["image"]),
|
150 |
outputs=[gr.Textbox(label="Status"), gr.File(label="Download Metadata")],
|
151 |
title="Geo-Metadata Extractor",
|
152 |
+
description="Upload images to extract metadata (including GPS) and automatically upload to latterworks/geo-metadata on Hugging Face Hub."
|
153 |
)
|
154 |
|
155 |
if __name__ == "__main__":
|