Spaces:
Running
Running
image preview fix
Browse files
frontend/src/pages/UploadPage/UploadPage.tsx
CHANGED
|
@@ -558,7 +558,7 @@ export default function UploadPage() {
|
|
| 558 |
{isLoading && (
|
| 559 |
<div className={styles.loadingContainer}>
|
| 560 |
<Spinner className="text-ifrcRed" />
|
| 561 |
-
|
| 562 |
</div>
|
| 563 |
)}
|
| 564 |
|
|
|
|
| 558 |
{isLoading && (
|
| 559 |
<div className={styles.loadingContainer}>
|
| 560 |
<Spinner className="text-ifrcRed" />
|
| 561 |
+
<p className={styles.loadingText}>Generating...</p>
|
| 562 |
</div>
|
| 563 |
)}
|
| 564 |
|
py_backend/app/config.py
CHANGED
|
@@ -15,7 +15,7 @@ class Settings(BaseSettings):
|
|
| 15 |
STORAGE_PROVIDER: str = "local"
|
| 16 |
STORAGE_DIR: str = "/data/uploads"
|
| 17 |
HF_HOME: str = "/data/.cache/huggingface"
|
| 18 |
-
BASE_URL: str = "
|
| 19 |
|
| 20 |
class Config:
|
| 21 |
env_file = ".env"
|
|
|
|
| 15 |
STORAGE_PROVIDER: str = "local"
|
| 16 |
STORAGE_DIR: str = "/data/uploads"
|
| 17 |
HF_HOME: str = "/data/.cache/huggingface"
|
| 18 |
+
BASE_URL: str = "https://huggingface.co/spaces/promptAId/Promptaid-VIsion"
|
| 19 |
|
| 20 |
class Config:
|
| 21 |
env_file = ".env"
|
py_backend/app/routers/caption.py
CHANGED
|
@@ -144,7 +144,7 @@ async def create_caption(
|
|
| 144 |
except Exception:
|
| 145 |
url = f"/api/images/{c.image_id}/file"
|
| 146 |
|
| 147 |
-
if url and url.startswith('/'):
|
| 148 |
url = f"{settings.BASE_URL}{url}"
|
| 149 |
|
| 150 |
img_dict = convert_image_to_dict(c, url)
|
|
@@ -173,7 +173,7 @@ def get_caption(
|
|
| 173 |
url = f"/api/images/{caption.image_id}/file"
|
| 174 |
|
| 175 |
|
| 176 |
-
if url and url.startswith('/'):
|
| 177 |
url = f"{settings.BASE_URL}{url}"
|
| 178 |
|
| 179 |
img_dict = convert_image_to_dict(caption, url)
|
|
@@ -200,7 +200,7 @@ def get_captions_by_image(
|
|
| 200 |
except Exception:
|
| 201 |
url = f"/api/images/{caption.image_id}/file"
|
| 202 |
|
| 203 |
-
if url and url.startswith('/'):
|
| 204 |
url = f"{settings.BASE_URL}{url}"
|
| 205 |
|
| 206 |
img_dict = convert_image_to_dict(caption, url)
|
|
@@ -259,7 +259,7 @@ def update_caption(
|
|
| 259 |
except Exception:
|
| 260 |
url = f"/api/images/{caption.image_id}/file"
|
| 261 |
|
| 262 |
-
if url and url.startswith('/'):
|
| 263 |
url = f"{settings.BASE_URL}{url}"
|
| 264 |
|
| 265 |
img_dict = convert_image_to_dict(caption, url)
|
|
|
|
| 144 |
except Exception:
|
| 145 |
url = f"/api/images/{c.image_id}/file"
|
| 146 |
|
| 147 |
+
if url and url.startswith('/') and settings.BASE_URL:
|
| 148 |
url = f"{settings.BASE_URL}{url}"
|
| 149 |
|
| 150 |
img_dict = convert_image_to_dict(c, url)
|
|
|
|
| 173 |
url = f"/api/images/{caption.image_id}/file"
|
| 174 |
|
| 175 |
|
| 176 |
+
if url and url.startswith('/') and settings.BASE_URL:
|
| 177 |
url = f"{settings.BASE_URL}{url}"
|
| 178 |
|
| 179 |
img_dict = convert_image_to_dict(caption, url)
|
|
|
|
| 200 |
except Exception:
|
| 201 |
url = f"/api/images/{caption.image_id}/file"
|
| 202 |
|
| 203 |
+
if url and url.startswith('/') and settings.BASE_URL:
|
| 204 |
url = f"{settings.BASE_URL}{url}"
|
| 205 |
|
| 206 |
img_dict = convert_image_to_dict(caption, url)
|
|
|
|
| 259 |
except Exception:
|
| 260 |
url = f"/api/images/{caption.image_id}/file"
|
| 261 |
|
| 262 |
+
if url and url.startswith('/') and settings.BASE_URL:
|
| 263 |
url = f"{settings.BASE_URL}{url}"
|
| 264 |
|
| 265 |
img_dict = convert_image_to_dict(caption, url)
|
py_backend/app/routers/upload.py
CHANGED
|
@@ -36,7 +36,8 @@ def convert_image_to_dict(img, image_url):
|
|
| 36 |
print(f"Warning: Error processing countries for image {img.image_id}: {e}")
|
| 37 |
countries_list = []
|
| 38 |
|
| 39 |
-
if
|
|
|
|
| 40 |
image_url = f"{settings.BASE_URL}{image_url}"
|
| 41 |
|
| 42 |
img_dict = {
|
|
|
|
| 36 |
print(f"Warning: Error processing countries for image {img.image_id}: {e}")
|
| 37 |
countries_list = []
|
| 38 |
|
| 39 |
+
# Handle image URL - if BASE_URL is set, use it; otherwise keep relative URLs
|
| 40 |
+
if image_url and image_url.startswith('/') and settings.BASE_URL:
|
| 41 |
image_url = f"{settings.BASE_URL}{image_url}"
|
| 42 |
|
| 43 |
img_dict = {
|