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