Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -25,42 +25,17 @@ ACTOR_VIDEOS = {
|
|
25 |
},
|
26 |
}
|
27 |
|
28 |
-
|
29 |
-
def change_video(actor_name):
|
30 |
-
video_url = ACTOR_VIDEOS[actor_name]["video_url"]
|
31 |
-
return f'<video width="100%" controls autoplay><source src="{video_url}" type="video/mp4"></video>'
|
32 |
-
|
33 |
-
# Create custom HTML input for actor images
|
34 |
-
actor_names = list(ACTOR_VIDEOS.keys())
|
35 |
-
|
36 |
-
# Initial actor selection (you can set this to any default actor)
|
37 |
-
initial_actor = "Original"
|
38 |
-
|
39 |
-
html_input_parts = ['<div>\n<style>.selected {border: 3px solid #FFD700; border-radius: 5px;}</style>']
|
40 |
-
|
41 |
-
for name in actor_names:
|
42 |
-
img_part = f'<img id="{name}" src="{ACTOR_VIDEOS[name]["image_url"]}" alt="{name}" style="width:100%; max-width:150px; cursor:pointer; margin: 5px;'
|
43 |
-
|
44 |
-
if name == initial_actor:
|
45 |
-
img_part += ' class=\'selected\''
|
46 |
-
|
47 |
-
img_part += f'" onclick="for (let img of document.getElementsByTagName(\'img\')) {{ img.classList.remove(\'selected\'); }}; this.classList.add(\'selected\'); Gradio.inputs[0].value = \'{name}\'; Gradio.submit();" />'
|
48 |
-
|
49 |
-
html_input_parts.append(img_part)
|
50 |
-
|
51 |
-
html_input_parts.append('</div>')
|
52 |
-
|
53 |
-
html_input = "\n".join(html_input_parts)
|
54 |
|
|
|
|
|
55 |
|
56 |
-
# Create Gradio Interface
|
57 |
iface = gr.Interface(
|
58 |
-
fn=
|
59 |
-
inputs=gr.HTML(html=
|
60 |
-
outputs=
|
61 |
-
live=True
|
62 |
-
title="Black Mirror Meets The Office: Michael Scott Is Awful",
|
63 |
-
description="Choose an actor below and watch them step into the shoes of Michael Scott"
|
64 |
)
|
65 |
|
66 |
iface.launch()
|
|
|
|
25 |
},
|
26 |
}
|
27 |
|
28 |
+
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
+
def test_html(inp):
|
31 |
+
return f"You selected: {inp}"
|
32 |
|
|
|
33 |
iface = gr.Interface(
|
34 |
+
fn=test_html,
|
35 |
+
inputs=gr.HTML(html='<button onclick="Gradio.inputs[0].value = \'Hello\'; Gradio.submit();">Click me</button>'),
|
36 |
+
outputs="text",
|
37 |
+
live=True
|
|
|
|
|
38 |
)
|
39 |
|
40 |
iface.launch()
|
41 |
+
|