SuriRaja commited on
Commit
f918f30
1 Parent(s): 3e374e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import torch
2
- from transformers import AutoModelForCausalLM, AutoTokenizer
3
  from diffusers import StableDiffusionPipeline
4
  import gradio as gr
 
5
 
6
  # Load the model and pipeline
7
  model_id = "ares1123/virtual-dress-try-on"
@@ -9,8 +9,24 @@ pipeline = StableDiffusionPipeline.from_pretrained(model_id)
9
  pipeline.to("cuda" if torch.cuda.is_available() else "cpu")
10
 
11
  def virtual_try_on(image, clothing_image):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  # Process the images using the model
13
- try_on_image = pipeline(image, clothing_image).images[0]
 
 
14
  return try_on_image
15
 
16
  # Set up a simple Gradio interface for testing
 
1
  import torch
 
2
  from diffusers import StableDiffusionPipeline
3
  import gradio as gr
4
+ from PIL import Image
5
 
6
  # Load the model and pipeline
7
  model_id = "ares1123/virtual-dress-try-on"
 
9
  pipeline.to("cuda" if torch.cuda.is_available() else "cpu")
10
 
11
  def virtual_try_on(image, clothing_image):
12
+ # Convert images to proper format and get dimensions
13
+ width, height = image.size
14
+
15
+ # Ensure dimensions are multiples of 8
16
+ width = (width // 8) * 8
17
+ height = (height // 8) * 8
18
+
19
+ # Resize images to fit the model's expected input
20
+ image = image.resize((width, height))
21
+ clothing_image = clothing_image.resize((width, height))
22
+
23
+ # Define a prompt describing what you want the model to do
24
+ prompt = "A person wearing new clothes"
25
+
26
  # Process the images using the model
27
+ result = pipeline(prompt=prompt, image=image, conditioning_image=clothing_image)
28
+ try_on_image = result.images[0]
29
+
30
  return try_on_image
31
 
32
  # Set up a simple Gradio interface for testing