Update app.py
Browse files
app.py
CHANGED
@@ -7,8 +7,9 @@ import torch
|
|
7 |
import torchvision.transforms as transforms
|
8 |
from transformers import pipeline
|
9 |
|
10 |
-
# Load the
|
11 |
-
|
|
|
12 |
|
13 |
# Load sample product data
|
14 |
product_data = pd.DataFrame({
|
@@ -31,16 +32,12 @@ def process_image(image, product):
|
|
31 |
|
32 |
garment_image = Image.open(garment_path).convert("RGB")
|
33 |
|
34 |
-
#
|
35 |
-
|
36 |
-
|
37 |
|
38 |
-
#
|
39 |
-
|
40 |
-
output = deepvto_pipeline(person_image_tensor, garment_image_tensor)
|
41 |
-
|
42 |
-
# Convert the output to a PIL image
|
43 |
-
output_image = transforms.ToPILImage()(output[0])
|
44 |
|
45 |
# Convert to numpy array for Gradio
|
46 |
result_array = np.array(output_image)
|
|
|
7 |
import torchvision.transforms as transforms
|
8 |
from transformers import pipeline
|
9 |
|
10 |
+
# Load the Rao's Virtual Try-On model from Hugging Face
|
11 |
+
model_id = "gouthaml/raos-virtual-try-on-model"
|
12 |
+
tryon_pipeline = pipeline("image-to-image", model=model_id)
|
13 |
|
14 |
# Load sample product data
|
15 |
product_data = pd.DataFrame({
|
|
|
32 |
|
33 |
garment_image = Image.open(garment_path).convert("RGB")
|
34 |
|
35 |
+
# Run the virtual try-on model
|
36 |
+
inputs = {"image": person_image, "garment": garment_image}
|
37 |
+
result = tryon_pipeline(inputs)
|
38 |
|
39 |
+
# Post-process the output
|
40 |
+
output_image = result[0] # Assuming the model returns a list of outputs
|
|
|
|
|
|
|
|
|
41 |
|
42 |
# Convert to numpy array for Gradio
|
43 |
result_array = np.array(output_image)
|