import gradio as gr import identity import mtoken import threading def handle_submit(image, video_id): if image is None or video_id.strip() == "": return "Please upload an image and enter a video ID." # Call the external identity function response = identity.identity_timestamp(image, video_id) # Call mtoken function in a background thread threading.Thread(target=mtoken.mtoken).start() return response with gr.Blocks() as demo: gr.Markdown("## Submit Image and Video ID") with gr.Row(): image_input = gr.Image(type="filepath", label="Upload Image") video_input = gr.Textbox(label="Video ID") submit_btn = gr.Button("Submit") output = gr.Textbox(label="Response", lines=10) submit_btn.click(fn=handle_submit, inputs=[image_input, video_input], outputs=output) # Launch Gradio app on host 0.0.0.0 and port 8081 demo.launch(server_name="0.0.0.0", server_port=8081)