sitatech commited on
Commit
38de8af
·
1 Parent(s): 5a39cf1

Fix Placeholder Image url

Browse files
Files changed (3) hide show
  1. app.py +0 -1
  2. mcp_host/ui.py +5 -1
  3. utils.py +6 -5
app.py CHANGED
@@ -1,6 +1,5 @@
1
  from __future__ import annotations
2
 
3
- import asyncio
4
  from typing import TYPE_CHECKING
5
 
6
  import gradio as gr
 
1
  from __future__ import annotations
2
 
 
3
  from typing import TYPE_CHECKING
4
 
5
  import gradio as gr
mcp_host/ui.py CHANGED
@@ -1,10 +1,14 @@
1
  import gradio as gr
2
 
 
 
3
 
4
  def UI(products_state: gr.State, image_state: gr.State):
5
  ui_container = gr.HTML(
6
  # Placeholder for initial UI
7
- FullSizeImage("/static/welcome-to-vibe-shopping.webp"),
 
 
8
  container=True,
9
  )
10
 
 
1
  import gradio as gr
2
 
3
+ from utils import get_hf_space_file_url_prefix
4
+
5
 
6
  def UI(products_state: gr.State, image_state: gr.State):
7
  ui_container = gr.HTML(
8
  # Placeholder for initial UI
9
+ FullSizeImage(
10
+ f"{get_hf_space_file_url_prefix()}static/welcome-to-vibe-shopping.webp"
11
+ ),
12
  container=True,
13
  )
14
 
utils.py CHANGED
@@ -10,10 +10,6 @@ class ImageUploader:
10
  upload images to any other server by overriding the `upload_image` method.
11
  """
12
 
13
- def _get_space_url(self):
14
- space_host = os.getenv("SPACE_HOST")
15
- return f"https://{space_host}"
16
-
17
  def upload_image(self, image: bytes | Image.Image, filename: str) -> str:
18
  """
19
  Upload an image to the server and return its URL.
@@ -31,7 +27,7 @@ class ImageUploader:
31
  with open(file_path, "wb") as f:
32
  f.write(image)
33
 
34
- return f"{self._get_space_url()}/gradio_api/file={file_path}"
35
 
36
 
37
  def pil_to_bytes(image, format: str = "PNG") -> bytes:
@@ -48,3 +44,8 @@ def pil_to_bytes(image, format: str = "PNG") -> bytes:
48
  buffer = BytesIO()
49
  image.save(buffer, format=format)
50
  return buffer.getvalue()
 
 
 
 
 
 
10
  upload images to any other server by overriding the `upload_image` method.
11
  """
12
 
 
 
 
 
13
  def upload_image(self, image: bytes | Image.Image, filename: str) -> str:
14
  """
15
  Upload an image to the server and return its URL.
 
27
  with open(file_path, "wb") as f:
28
  f.write(image)
29
 
30
+ return f"{get_hf_space_file_url_prefix()}{file_path}"
31
 
32
 
33
  def pil_to_bytes(image, format: str = "PNG") -> bytes:
 
44
  buffer = BytesIO()
45
  image.save(buffer, format=format)
46
  return buffer.getvalue()
47
+
48
+
49
+ def get_hf_space_file_url_prefix() -> str:
50
+ space_host = os.getenv("SPACE_HOST")
51
+ return f"https://{space_host}/gradio_api/file="