Spaces:
Running
Running
Create label.py
Browse files
label.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import identity
|
3 |
+
import mtoken
|
4 |
+
import threading
|
5 |
+
|
6 |
+
def handle_submit(image, video_id):
|
7 |
+
if image is None or video_id.strip() == "":
|
8 |
+
return "Please upload an image and enter a video ID."
|
9 |
+
|
10 |
+
# Call the external identity function
|
11 |
+
response = identity.identity_timestamp(image, video_id)
|
12 |
+
|
13 |
+
# Call mtoken function in a background thread
|
14 |
+
threading.Thread(target=mtoken.mtoken).start()
|
15 |
+
|
16 |
+
return response
|
17 |
+
|
18 |
+
with gr.Blocks() as demo:
|
19 |
+
gr.Markdown("## Submit Image and Video ID")
|
20 |
+
|
21 |
+
with gr.Row():
|
22 |
+
image_input = gr.Image(type="filepath", label="Upload Image")
|
23 |
+
video_input = gr.Textbox(label="Video ID")
|
24 |
+
|
25 |
+
submit_btn = gr.Button("Submit")
|
26 |
+
output = gr.Textbox(label="Response", lines=10)
|
27 |
+
|
28 |
+
submit_btn.click(fn=handle_submit, inputs=[image_input, video_input], outputs=output)
|
29 |
+
|
30 |
+
# Launch Gradio app on host 0.0.0.0 and port 8081
|
31 |
+
demo.launch(server_name="0.0.0.0", server_port=8081)
|