AI-ANK commited on
Commit
fc21828
1 Parent(s): 4d08abd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -33
app.py CHANGED
@@ -25,42 +25,17 @@ ACTOR_VIDEOS = {
25
  },
26
  }
27
 
28
- # Function to change video based on actor selection
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=change_video,
59
- inputs=gr.HTML(html=html_input, live=True),
60
- outputs=gr.HTML(label="Your Video"),
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
+