Spaces:
Sleeping
Sleeping
GeorgeSherif commited on
Commit ·
1349bfa
1
Parent(s): 87ee9b6
update
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import threading
|
|
| 4 |
import random
|
| 5 |
from datasets import load_dataset, Dataset, Features, Value, concatenate_datasets
|
| 6 |
from huggingface_hub import login
|
|
|
|
| 7 |
# Authenticate with Hugging Face
|
| 8 |
token = os.getenv("HUGGINGFACE_TOKEN")
|
| 9 |
if token:
|
|
@@ -29,6 +30,12 @@ except Exception as e:
|
|
| 29 |
dataset["train"].push_to_hub(f"{dataset_name}", split="train")
|
| 30 |
dataset["val"].push_to_hub(f"{dataset_name}", split="val")
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
image_folder = "test"
|
| 33 |
image_files = [f for f in os.listdir(image_folder) if f.endswith(('.png', '.jpg', '.jpeg'))]
|
| 34 |
lock = threading.Lock()
|
|
@@ -117,4 +124,4 @@ with gr.Blocks() as demo:
|
|
| 117 |
# Load initial image
|
| 118 |
demo.load(fn=initialize_interface, inputs=session_data, outputs=[image, caption])
|
| 119 |
|
| 120 |
-
demo.launch(share=True)
|
|
|
|
| 4 |
import random
|
| 5 |
from datasets import load_dataset, Dataset, Features, Value, concatenate_datasets
|
| 6 |
from huggingface_hub import login
|
| 7 |
+
|
| 8 |
# Authenticate with Hugging Face
|
| 9 |
token = os.getenv("HUGGINGFACE_TOKEN")
|
| 10 |
if token:
|
|
|
|
| 30 |
dataset["train"].push_to_hub(f"{dataset_name}", split="train")
|
| 31 |
dataset["val"].push_to_hub(f"{dataset_name}", split="val")
|
| 32 |
|
| 33 |
+
# Verify that both splits are in the dataset
|
| 34 |
+
if "train" not in dataset:
|
| 35 |
+
dataset["train"] = Dataset.from_dict({'image_id': [], 'caption': []}, features=features)
|
| 36 |
+
if "val" not in dataset:
|
| 37 |
+
dataset["val"] = Dataset.from_dict({'image_id': [], 'caption': []}, features=features)
|
| 38 |
+
|
| 39 |
image_folder = "test"
|
| 40 |
image_files = [f for f in os.listdir(image_folder) if f.endswith(('.png', '.jpg', '.jpeg'))]
|
| 41 |
lock = threading.Lock()
|
|
|
|
| 124 |
# Load initial image
|
| 125 |
demo.load(fn=initialize_interface, inputs=session_data, outputs=[image, caption])
|
| 126 |
|
| 127 |
+
demo.launch(share=True)
|