rootglitch commited on
Commit
ffea83e
·
1 Parent(s): 413b0e5

Debug file path

Browse files
Files changed (1) hide show
  1. app.py +20 -19
app.py CHANGED
@@ -327,35 +327,36 @@ def run_grounded_sam(
327
  else:
328
  return [Image.new('RGB', (400, 300), color='gray'), Image.new('RGBA', (400, 300), color=(0, 0, 0, 0))]
329
 
330
- def upload_file(file: UploadFile):
331
- file_path = os.path.join(UPLOAD_DIR, file.filename)
332
- with open(file_path, "wb") as buffer:
333
- shutil.copyfileobj(file.file, buffer)
 
334
 
335
  # Return URL
336
- return {"url": f"https://huggingface.co/spaces/rootglitch/CarVizGradioDemo01/{file_path}"}
337
 
338
  def generate_ai_bg(input_img, prompt):
339
  hf_input_img = upload_file(input_img)["url"]
340
 
341
- handler = fal_client.submit(
342
- "fal-ai/iclight-v2",
343
- arguments={
344
- "prompt": prompt,
345
- "image_url": hf_input_img
346
- },
347
- webhook_url="https://optional.webhook.url/for/results",
348
- )
349
 
350
- request_id = handler.request_id
351
 
352
- status = fal_client.status("fal-ai/iclight-v2", request_id, with_logs=True)
353
 
354
- result = fal_client.result("fal-ai/iclight-v2", request_id)
355
 
356
- ic_light_img = result['images'][0]['url']
357
 
358
- return ic_light_img
359
 
360
  def generate_image(input_img, prompt):
361
  ai_gen_image = generate_ai_bg(input_img, prompt)
@@ -371,7 +372,7 @@ def create_ui():
371
 
372
  with gr.Row():
373
  with gr.Column():
374
- input_image = gr.Image(type="filepath", label="image")
375
  prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
376
  run_button = gr.Button(value='Run')
377
 
 
327
  else:
328
  return [Image.new('RGB', (400, 300), color='gray'), Image.new('RGBA', (400, 300), color=(0, 0, 0, 0))]
329
 
330
+ def upload_file(img_file):
331
+ file_path = os.path.join(UPLOAD_DIR, 'input_image.png')
332
+ image.save(file_path)
333
+ print('file_path = ', file_path)
334
+ print('hf_file_path = ', f"https://huggingface.co/spaces/rootglitch/CarVizGradioDemo01/{file_path}")
335
 
336
  # Return URL
337
+ return file_path
338
 
339
  def generate_ai_bg(input_img, prompt):
340
  hf_input_img = upload_file(input_img)["url"]
341
 
342
+ # handler = fal_client.submit(
343
+ # "fal-ai/iclight-v2",
344
+ # arguments={
345
+ # "prompt": prompt,
346
+ # "image_url": hf_input_img
347
+ # },
348
+ # webhook_url="https://optional.webhook.url/for/results",
349
+ # )
350
 
351
+ # request_id = handler.request_id
352
 
353
+ # status = fal_client.status("fal-ai/iclight-v2", request_id, with_logs=True)
354
 
355
+ # result = fal_client.result("fal-ai/iclight-v2", request_id)
356
 
357
+ # ic_light_img = result['images'][0]['url']
358
 
359
+ # return ic_light_img
360
 
361
  def generate_image(input_img, prompt):
362
  ai_gen_image = generate_ai_bg(input_img, prompt)
 
372
 
373
  with gr.Row():
374
  with gr.Column():
375
+ input_image = gr.Image(type="pil", label="image")
376
  prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
377
  run_button = gr.Button(value='Run')
378