ysharma HF Staff commited on
Commit
ff5c4be
·
verified ·
1 Parent(s): bff45b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -554,6 +554,13 @@ def create_app():
554
  "Image loaded — hover the viewer and click an arrow to generate",
555
  )
556
 
 
 
 
 
 
 
 
557
  def on_camera_submit(
558
  current_view, src_img,
559
  seed_val, rand_seed, guidance, steps, h, w,
@@ -563,6 +570,10 @@ def create_app():
563
  az, el, dist = _coerce_view(current_view)
564
  prompt = build_camera_prompt(az, el, dist)
565
 
 
 
 
 
566
  if src_img is None:
567
  return current_view, prompt, "⚠ Upload an image first", gallery_imgs, gallery_imgs
568
 
 
554
  "Image loaded — hover the viewer and click an arrow to generate",
555
  )
556
 
557
+ def _img_from_data_url(data_url):
558
+ """Decode a base64 data URL back to a PIL Image."""
559
+ if not data_url or not data_url.startswith("data:"):
560
+ return None
561
+ header, b64 = data_url.split(",", 1)
562
+ return Image.open(BytesIO(base64.b64decode(b64)))
563
+
564
  def on_camera_submit(
565
  current_view, src_img,
566
  seed_val, rand_seed, guidance, steps, h, w,
 
570
  az, el, dist = _coerce_view(current_view)
571
  prompt = build_camera_prompt(az, el, dist)
572
 
573
+ # If no image in gr.Image, try the data URL from the viewer dropzone
574
+ if src_img is None and isinstance(current_view, dict):
575
+ src_img = _img_from_data_url(current_view.get("img", ""))
576
+
577
  if src_img is None:
578
  return current_view, prompt, "⚠ Upload an image first", gallery_imgs, gallery_imgs
579