Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"
|
8 |
+
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
|
17 |
+
interface = gr.Interface(
|
18 |
+
fn=virtual_try_on,
|
19 |
+
inputs=[gr.inputs.Image(type="pil", label="User Image"),
|
20 |
+
gr.inputs.Image(type="pil", label="Clothing Image")],
|
21 |
+
outputs="image",
|
22 |
+
title="Virtual Dress Try-On",
|
23 |
+
description="Upload an image of yourself and a clothing image to try it on virtually!"
|
24 |
+
)
|
25 |
+
|
26 |
+
# Launch the interface
|
27 |
+
interface.launch(share=True)
|