uruguayai commited on
Commit
c92f81a
·
verified ·
1 Parent(s): ef1c1db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  import torch
3
  from diffusers import DiffusionPipeline
 
4
 
5
  # Set up device
6
  device = "cuda" if torch.cuda.is_available() else "cpu"
@@ -13,18 +14,29 @@ except Exception as e:
13
 
14
  def process_image(prompt, image, style, upscale_factor, inpaint):
15
  try:
16
- # Convert the image to the appropriate format if needed
17
  if image is not None:
18
  image = image.convert("RGB")
19
 
 
 
 
 
 
 
20
  # Example placeholder logic for using the pipeline
21
- # Here we assume the pipeline can handle both image and prompt; adjust as needed
22
  if inpaint:
23
  result = inpaint_model(prompt=prompt, image=image, guidance_scale=7.5)
24
  else:
25
  result = inpaint_model(prompt=prompt, guidance_scale=7.5)
26
 
27
- return result.images[0] # Return the first image from the result
 
 
 
 
 
28
  except Exception as e:
29
  return f"Error in process_image function: {e}"
30
 
 
1
  import gradio as gr
2
  import torch
3
  from diffusers import DiffusionPipeline
4
+ from PIL import Image
5
 
6
  # Set up device
7
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
14
 
15
  def process_image(prompt, image, style, upscale_factor, inpaint):
16
  try:
17
+ # Ensure the image is in the correct format
18
  if image is not None:
19
  image = image.convert("RGB")
20
 
21
+ # Log the input parameters
22
+ print(f"Prompt: {prompt}")
23
+ print(f"Style: {style}")
24
+ print(f"Upscale Factor: {upscale_factor}")
25
+ print(f"Inpaint: {inpaint}")
26
+
27
  # Example placeholder logic for using the pipeline
28
+ # Replace with actual pipeline logic based on selected style
29
  if inpaint:
30
  result = inpaint_model(prompt=prompt, image=image, guidance_scale=7.5)
31
  else:
32
  result = inpaint_model(prompt=prompt, guidance_scale=7.5)
33
 
34
+ # Check if the result is valid
35
+ if result and hasattr(result, 'images') and len(result.images) > 0:
36
+ return result.images[0]
37
+ else:
38
+ return "Error: No image returned from model."
39
+
40
  except Exception as e:
41
  return f"Error in process_image function: {e}"
42