Spaces:
Sleeping
Sleeping
scontess
commited on
Commit
·
afbeecd
1
Parent(s):
984970c
ww1
Browse files- requirements.txt +2 -0
- src/streamlit_app.py +18 -0
requirements.txt
CHANGED
|
@@ -8,3 +8,5 @@ seaborn
|
|
| 8 |
datasets
|
| 9 |
scikit-learn
|
| 10 |
Pillow
|
|
|
|
|
|
|
|
|
| 8 |
datasets
|
| 9 |
scikit-learn
|
| 10 |
Pillow
|
| 11 |
+
requests
|
| 12 |
+
|
src/streamlit_app.py
CHANGED
|
@@ -15,6 +15,24 @@ from sklearn.model_selection import train_test_split
|
|
| 15 |
import os
|
| 16 |
from PIL import Image
|
| 17 |
import json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
|
|
|
|
| 15 |
import os
|
| 16 |
from PIL import Image
|
| 17 |
import json
|
| 18 |
+
import requests
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def download_image(image_url, save_path):
|
| 22 |
+
response = requests.get(image_url)
|
| 23 |
+
response.raise_for_status() # Verifica errori di connessione
|
| 24 |
+
with open(save_path, "wb") as f:
|
| 25 |
+
f.write(response.content)
|
| 26 |
+
|
| 27 |
+
# Costruisci i percorsi corretti
|
| 28 |
+
repo_base_path = "/tmp/huggingface/dataset/images/"
|
| 29 |
+
df["image_path"] = df["image"].apply(lambda x: os.path.join(repo_base_path, os.path.basename(x)))
|
| 30 |
+
|
| 31 |
+
# Scarica le immagini mancanti
|
| 32 |
+
for path in df["image_path"]:
|
| 33 |
+
if not os.path.exists(path): # Controlla se il file esiste già
|
| 34 |
+
image_url = f"https://huggingface.co/datasets/scontess/lissajous/resolve/main/dataset/images/{os.path.basename(path)}"
|
| 35 |
+
download_image(image_url, path) # Scarica il file
|
| 36 |
|
| 37 |
|
| 38 |
|