Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +14 -0
src/streamlit_app.py
CHANGED
|
@@ -7,6 +7,20 @@ import numpy as np
|
|
| 7 |
import chromadb
|
| 8 |
import tempfile
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# ----- Setup -----
|
| 11 |
CACHE_DIR = tempfile.gettempdir()
|
| 12 |
CHROMA_PATH = os.path.join(CACHE_DIR, "chroma_db")
|
|
|
|
| 7 |
import chromadb
|
| 8 |
import tempfile
|
| 9 |
|
| 10 |
+
# Create directory if not exists
|
| 11 |
+
os.makedirs("demo_images", exist_ok=True)
|
| 12 |
+
|
| 13 |
+
# Download 50 high-res (1024x768) random images
|
| 14 |
+
for i in tqdm(range(50), desc="Downloading images"):
|
| 15 |
+
url = f"https://picsum.photos/seed/{i}/1024/768"
|
| 16 |
+
response = requests.get(url)
|
| 17 |
+
if response.status_code == 200:
|
| 18 |
+
with open(f"demo_images/img_{i+1:02}.jpg", "wb") as f:
|
| 19 |
+
f.write(response.content)
|
| 20 |
+
else:
|
| 21 |
+
print(f"Failed to download image {i+1}")
|
| 22 |
+
|
| 23 |
+
|
| 24 |
# ----- Setup -----
|
| 25 |
CACHE_DIR = tempfile.gettempdir()
|
| 26 |
CHROMA_PATH = os.path.join(CACHE_DIR, "chroma_db")
|