Spaces:
Running
Running
File size: 1,535 Bytes
0017bb6 63c7d6c 3096da3 0017bb6 8e376f0 0017bb6 0d12119 63c7d6c 0017bb6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import os
import shutil
import gradio as gr
from PIL import Image
def process_images(cloth_image, origin_image):
# Convert numpy arrays to PIL images
cloth_image = Image.fromarray(cloth_image)
origin_image = Image.fromarray(origin_image)
print(cloth_image)
print(origin_image)
# Define the input directory
input_dir = 'TryYours-Virtual-Try-On/static'
print(input_dir)
# Ensure the directory exists
if not os.path.exists(input_dir):
os.makedirs(input_dir)
# Save the uploaded images to the input directory
cloth_image.save(os.path.join(input_dir, 'cloth_web.jpg'))
origin_image.save(os.path.join(input_dir, 'origin_web.jpg'))
print("saved")
# Run your main.py script (assuming it's in the same directory)
# Note: You might need to adjust the command based on your actual script's requirements
os.system("python TryYours-Virtual-Try-On/main.py ")
#command = ["python", "virtual-try-on/TryYours-Virtual-Try-On/main.py"]
#subprocess.run(command, check=True)
print("might run")
# Return the final image
final_image_path = os.path.join(input_dir, 'finalimg.png')
return final_image_path
garment_top = gr.Image(sources='upload', type="numpy")
garment_down = gr.Image(sources='upload', type="numpy")
demo = gr.Interface(process_images,inputs=[
garment_top,
garment_down,
], outputs=["image"])
demo.launch(share=True, debug=True) |