dkatz2391 commited on
Commit
bcfc50a
·
verified ·
1 Parent(s): 6dc0d71

hidden gradio element

Browse files
Files changed (1) hide show
  1. app.py +23 -21
app.py CHANGED
@@ -127,8 +127,8 @@ def extract_glb(
127
 
128
  @spaces.GPU(duration=180)
129
  def generate_model_from_images_and_upload(
130
- image_inputs_arg, # Temporarily change name to see raw input
131
- input_type_arg, # Temporarily change name
132
  seed_val: int,
133
  ss_guidance_strength_val: float,
134
  ss_sampling_steps_val: int,
@@ -143,22 +143,16 @@ def generate_model_from_images_and_upload(
143
  user_dir = os.path.join(TMP_DIR, str(req.session_hash))
144
  os.makedirs(user_dir, exist_ok=True)
145
 
146
- # --- START DEBUG LOGS ---
147
- print(f"DEBUG: Raw image_inputs_arg: {image_inputs_arg}")
148
- print(f"DEBUG: Type of image_inputs_arg: {type(image_inputs_arg)}")
149
- if isinstance(image_inputs_arg, list):
150
- print(f"DEBUG: Length of image_inputs_arg list: {len(image_inputs_arg)}")
151
- if len(image_inputs_arg) > 0:
152
- print(f"DEBUG: First element of image_inputs_arg: {image_inputs_arg[0]}")
153
- print(f"DEBUG: Type of first element: {type(image_inputs_arg[0])}")
154
  # --- END DEBUG LOGS ---
155
-
156
- # Assign to original names for the rest of the script to function if data is as expected
157
- # If image_inputs_arg is not what we expect (a list), this might error or behave unexpectedly
158
- image_inputs: List[str] = image_inputs_arg if isinstance(image_inputs_arg, list) else []
159
- input_type: str = input_type_arg if isinstance(input_type_arg, str) else ""
160
-
161
-
162
  print(f"Processed image_inputs: {image_inputs}, input_type: {input_type}") # Original log line
163
 
164
  pil_images = []
@@ -377,9 +371,17 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
377
  )
378
 
379
  # --- Add this section to explicitly register the API function for image to 3D ---
380
- # These State components are placeholders for API-only inputs
381
- api_image_inputs_state = gr.State(value=[]) # For List[str] of image_inputs
382
- api_input_type_state = gr.State(value="url") # For input_type: "url", "filepath", or "base64"
 
 
 
 
 
 
 
 
383
  api_model_description_state = gr.State(value="ImagenModel") # For model_description
384
 
385
  with gr.Row(visible=False): # Hide this row in the UI
@@ -391,7 +393,7 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
391
  api_image_gen_trigger_btn.click(
392
  generate_model_from_images_and_upload,
393
  inputs=[ # Order must match the Python function's parameters
394
- api_image_inputs_state,
395
  api_input_type_state,
396
  seed, # UI component
397
  ss_guidance_strength, # UI component
 
127
 
128
  @spaces.GPU(duration=180)
129
  def generate_model_from_images_and_upload(
130
+ image_inputs: List[str],
131
+ input_type: str,
132
  seed_val: int,
133
  ss_guidance_strength_val: float,
134
  ss_sampling_steps_val: int,
 
143
  user_dir = os.path.join(TMP_DIR, str(req.session_hash))
144
  os.makedirs(user_dir, exist_ok=True)
145
 
146
+ # --- KEEP DEBUG LOGS for this test run ---
147
+ print(f"DEBUG: Raw image_inputs (as received by function): {image_inputs}")
148
+ print(f"DEBUG: Type of image_inputs: {type(image_inputs)}")
149
+ if isinstance(image_inputs, list):
150
+ print(f"DEBUG: Length of image_inputs list: {len(image_inputs)}")
151
+ if len(image_inputs) > 0:
152
+ print(f"DEBUG: First element of image_inputs: {image_inputs[0]}")
153
+ print(f"DEBUG: Type of first element: {type(image_inputs[0])}")
154
  # --- END DEBUG LOGS ---
155
+
 
 
 
 
 
 
156
  print(f"Processed image_inputs: {image_inputs}, input_type: {input_type}") # Original log line
157
 
158
  pil_images = []
 
371
  )
372
 
373
  # --- Add this section to explicitly register the API function for image to 3D ---
374
+ # Use gr.File for image_inputs for better API handling of URL lists
375
+ # This component will be hidden and only used for the API definition.
376
+ api_image_files_placeholder = gr.File(
377
+ label="API Image Input Placeholder",
378
+ file_count="multiple", # Allows a list of files/URLs
379
+ visible=False,
380
+ interactive=False # Not for UI interaction
381
+ )
382
+
383
+ # input_type still needed to differentiate between URL, base64, filepath
384
+ api_input_type_state = gr.State(value="url")
385
  api_model_description_state = gr.State(value="ImagenModel") # For model_description
386
 
387
  with gr.Row(visible=False): # Hide this row in the UI
 
393
  api_image_gen_trigger_btn.click(
394
  generate_model_from_images_and_upload,
395
  inputs=[ # Order must match the Python function's parameters
396
+ api_image_files_placeholder, # <--- CHANGED: Use the gr.File component here
397
  api_input_type_state,
398
  seed, # UI component
399
  ss_guidance_strength, # UI component