Spaces:
Runtime error
Runtime error
lixiang46 commited on
Commit ·
efa1709
1
Parent(s): b453f9d
test
Browse files11 unmodified lines12131415161718192017 unmodified lines38394041424373 unmodified lines11711811912012112211 unmodified linesdef start_tryon(person_img, garment_img, seed, randomize_seed):if randomize_seed:seed = random.randint(0, MAX_SEED)encoded_person_img = cv2.imencode('.jpg', person_img)[1].tobytes()encoded_person_img = base64.b64encode(encoded_person_img).decode('utf-8')encoded_garment_img = cv2.imencode('.jpg', garment_img)[1].tobytes()encoded_garment_img = base64.b64encode(encoded_garment_img).decode('utf-8')url = "https://" + os.environ['tryon_url']17 unmodified linesresult = base64.b64decode(result['result'])result_np = np.frombuffer(result, np.uint8)result_img = cv2.imdecode(result_np, cv2.IMREAD_UNCHANGED)info = "Success"else:info = "Try again latter"73 unmodified linestry_button.click(fn=start_tryon, inputs=[imgs, garm_img, seed, randomize_seed], outputs=[image_out, seed_used, result_info], api_name='tryon')ip = requests.get('http://ifconfig.me/ip', timeout=1).text.strip()print("ip address", ip)Tryon.queue(max_size=10).launch()11 unmodified lines12131415161718192017 unmodified lines3839404142434473 unmodified lines11811912012112212312412512612712811 unmodified linesdef start_tryon(person_img, garment_img, seed, randomize_seed):if randomize_seed:seed = random.randint(0, MAX_SEED)encoded_person_img = cv2.imencode('.jpg', cv2.cv2Colors(person_img, cv2.COLOR_RGB2BGR))[1].tobytes()encoded_person_img = base64.b64encode(encoded_person_img).decode('utf-8')encoded_garment_img = cv2.imencode('.jpg', cv2.cv2Colors(garment_img, cv2.COLOR_RGB2BGR))[1].tobytes()encoded_garment_img = base64.b64encode(encoded_garment_img).decode('utf-8')url = "https://" + os.environ['tryon_url']17 unmodified linesresult = base64.b64decode(result['result'])result_np = np.frombuffer(result, np.uint8)result_img = cv2.imdecode(result_np, cv2.IMREAD_UNCHANGED)result_img = cv2.cv2Colors(result_img, cv2.COLOR_RGB2BGR)info = "Success"else:info = "Try again latter"73 unmodified linestry_button.click(fn=start_tryon, inputs=[imgs, garm_img, seed, randomize_seed], outputs=[image_out, seed_used, result_info], api_name='tryon')# with gr.Row(label="Examples"):# with gr.Column(elem_id = "col-left"):# imgs = gr.Image(label="Person image", sources='upload', type="numpy")ip = requests.get('http://ifconfig.me/ip', timeout=1).text.strip()print("ip address", ip)Tryon.queue(max_size=10).launch()
app.py+8-2