abdullahalioo commited on
Commit
ca38edc
·
verified ·
1 Parent(s): 57c93ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -1,21 +1,26 @@
1
  import gradio as gr
2
- from diffusion_single_file import load_model, enhance_image
 
3
 
4
- # Load the ZenCtrl model using the correct library
5
- model = load_model("fotographerai/zenctrl_tools")
 
6
 
7
- def enhance_image_fn(input_image):
8
- # Enhance the image using the model
9
- enhanced_image = enhance_image(model, input_image)
10
- return enhanced_image
 
 
 
11
 
12
  # Set up the Gradio interface
13
  interface = gr.Interface(
14
- fn=enhance_image_fn,
15
  inputs=gr.Image(type="pil", label="Upload Image to Enhance"),
16
  outputs=gr.Image(type="pil", label="Enhanced Image"),
17
- title="Image Enhancement with ZenCtrl",
18
- description="Upload an image to enhance it using FotographerAI's ZenCtrl tools. Enhance your photos with AI!",
19
  live=True
20
  )
21
 
 
1
  import gradio as gr
2
+ import torch
3
+ from diffusers import StableDiffusionPipeline
4
 
5
+ # Load the image enhancement model
6
+ model_id = "fotographerai/zenctrl_tools"
7
+ device = "cuda" if torch.cuda.is_available() else "cpu"
8
 
9
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16 if device == "cuda" else torch.float32)
10
+ pipe.to(device)
11
+
12
+ def enhance_image(image):
13
+ # Process the image using the AI model
14
+ result = pipe(image).images[0] # Get the first enhanced image
15
+ return result
16
 
17
  # Set up the Gradio interface
18
  interface = gr.Interface(
19
+ fn=enhance_image,
20
  inputs=gr.Image(type="pil", label="Upload Image to Enhance"),
21
  outputs=gr.Image(type="pil", label="Enhanced Image"),
22
+ title="AI Image Enhancement",
23
+ description="Enhance your images using FotographerAI's ZenCtrl tools with AI!",
24
  live=True
25
  )
26