rajsecrets0 commited on
Commit
8406498
·
verified ·
1 Parent(s): 1da0d18

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -12
app.py CHANGED
@@ -1,21 +1,29 @@
1
  import gradio as gr
2
- from huggingface_hub import InferenceClient
 
 
3
 
4
- # Initialize the InferenceClient
5
- client = InferenceClient("models/black-forest-labs/FLUX.1-schnell")
6
 
7
  def merge_images(model_image, cloth_image):
8
- # Prepare the inputs for the model
9
- inputs = {
10
- "image_1": model_image,
11
- "image_2": cloth_image,
12
- }
13
 
14
- # Make the API call to the model
15
- output = client.post(json=inputs)
16
 
17
- # The output should be the merged image
18
- return output
 
 
 
 
 
 
 
 
19
 
20
  # Create the Gradio interface
21
  iface = gr.Interface(
 
1
  import gradio as gr
2
+ import torch
3
+ from diffusers import DiffusionPipeline
4
+ from PIL import Image
5
 
6
+ # Load the pipeline
7
+ pipeline = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell")
8
 
9
  def merge_images(model_image, cloth_image):
10
+ # Save uploaded images temporarily
11
+ model_image.save("model_image.png")
12
+ cloth_image.save("cloth_image.png")
 
 
13
 
14
+ # Create prompt
15
+ prompt = f"A model wearing the clothing from the second image model_image.png and cloth_image.png"
16
 
17
+ # Generate the merged image
18
+ output_image = pipeline(
19
+ prompt,
20
+ guidance_scale=0.8,
21
+ num_inference_steps=4,
22
+ max_sequence_length=256,
23
+ generator=torch.Generator("cpu").manual_seed(0)
24
+ ).images[0]
25
+
26
+ return output_image
27
 
28
  # Create the Gradio interface
29
  iface = gr.Interface(