import os from typing import List, Optional, Tuple import gradio as gr import numpy as np import torch from PIL import Image from huggingface_hub import snapshot_download # Assume these modules are in the same directory or properly installed from module.pipeline_fastfit import FastFitPipeline from parse_utils import DWposeDetector, DensePose, SCHP, multi_ref_cloth_agnostic_mask PERSON_SIZE = (768, 1024) # --- Translation Dictionary --- # All user-facing text is stored here for easy management translations = { "zh": { "language": "
💡 建议上传 3:4 宽高比的全身人物图像,其他比例会被自动中心裁剪
', "person_image_label": "上传待换装的人物图像", "ref_garment_header": "⚠️ 约束条件:裙子不能与上衣或下衣同时上传
', "upper_body_label": "上衣", "lower_body_label": "下衣", "dress_label": "裙子/连体装", "shoes_label": "鞋子", "bag_label": "包包", "generate_params": "💡 Suggest uploading a full-body shot with a 3:4 aspect ratio. Others will be center-cropped.
', "person_image_label": "Upload an image of the person to try on", "ref_garment_header": "⚠️ Constraint: A dress cannot be uploaded with a top or bottom.
', "upper_body_label": "Top", "lower_body_label": "Bottom", "dress_label": "Dress / Overall", "shoes_label": "Shoes", "bag_label": "Bag", "generate_params": "{status_message}
' else: styled_message = f'{status_message}
' return img, styled_message generate_btn.click( fn=generation_wrapper, inputs=[ lang_state, person_image, upper_image, lower_image, dress_image, shoe_image, bag_image, ref_size, num_steps, guidance_scale, use_square_mask, seed, enable_pose ], outputs=[output_image, status_text] ) return demo if __name__ == "__main__": demo = create_demo() demo.launch( server_name="0.0.0.0", server_port=7860, share=False, show_error=True )