Brian Watson commited on
Commit
2c77f68
·
1 Parent(s): 6e84ffe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -38
app.py CHANGED
@@ -1,7 +1,4 @@
1
  import gradio as gr
2
- import os
3
- import sys
4
- from pathlib import Path
5
 
6
  models = [
7
  {"name": "Claudfuen 1", "url": "claudfuen/photorealistic-fuen-v1"},
@@ -37,54 +34,43 @@ def send_it(inputs, model_choice):
37
  return proc(inputs)
38
 
39
 
40
- css = """"""
41
-
42
- with gr.Blocks(css=css) as myface:
43
- gr.HTML(
44
- """<!DOCTYPE html>
45
- <html lang="en">
46
- <head>
47
- <meta charset="utf-8" />
48
- <meta name="twitter:card" content="player"/>
49
- <meta name="twitter:site" content=""/>
50
- <meta name="twitter:player" content="https://omnibus-maximum-multiplier-places.hf.space"/>
51
- <meta name="twitter:player:stream" content="https://omnibus-maximum-multiplier-places.hf.space"/>
52
- <meta name="twitter:player:width" content="100%"/>
53
- <meta name="twitter:player:height" content="600"/>
54
- <meta property="og:title" content="Embedded Live Viewer"/>
55
- <meta property="og:description" content="Tweet Genie - A Huggingface Space"/>
56
- <meta property="og:image" content="https://cdn.glitch.global/80dbe92e-ce75-44af-84d5-74a2e21e9e55/omnicard.png?v=1676772531627"/>
57
- <!--<meta http-equiv="refresh" content="0; url=https://huggingface.co/spaces/corbt/tweet-genie">-->
58
  <script>
59
- function makeDropdownSearchable(dropdownId) {
60
  const input = document.getElementById(dropdownId);
61
- input.addEventListener("input", function() {
62
  const value = this.value.toLowerCase();
63
  const options = document.querySelectorAll(`#${dropdownId} option`);
64
  let found = false;
65
- for (let i = 0; i < options.length; i++) {
66
  const option = options[i];
67
  const text = option.text.toLowerCase();
68
  const match = text.includes(value);
69
  option.style.display = match ? "block" : "none";
70
- if (match) {
71
  found = true;
72
- }
73
- }
74
- if (value && !found) {
75
  const firstOption = options[0];
76
- if (firstOption) {
77
  firstOption.selected = true;
78
- }
79
- }
80
- });
81
- }
82
- makeDropdownSearchable("model_dropdown");
 
83
  </script>
84
- </head>
85
- </html>
86
- """
87
- )
 
 
 
 
88
 
89
  with gr.Row():
90
  with gr.Row():
 
1
  import gradio as gr
 
 
 
2
 
3
  models = [
4
  {"name": "Claudfuen 1", "url": "claudfuen/photorealistic-fuen-v1"},
 
34
  return proc(inputs)
35
 
36
 
37
+ def make_dropdown_searchable(dropdown_id):
38
+ script = f"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  <script>
40
+ function makeDropdownSearchable(dropdownId) {{
41
  const input = document.getElementById(dropdownId);
42
+ input.addEventListener("input", function() {{
43
  const value = this.value.toLowerCase();
44
  const options = document.querySelectorAll(`#${dropdownId} option`);
45
  let found = false;
46
+ for (let i = 0; i < options.length; i++) {{
47
  const option = options[i];
48
  const text = option.text.toLowerCase();
49
  const match = text.includes(value);
50
  option.style.display = match ? "block" : "none";
51
+ if (match) {{
52
  found = true;
53
+ }}
54
+ }}
55
+ if (value && !found) {{
56
  const firstOption = options[0];
57
+ if (firstOption) {{
58
  firstOption.selected = true;
59
+ }}
60
+ }}
61
+ }});
62
+ }}
63
+
64
+ makeDropdownSearchable("{dropdown_id}");
65
  </script>
66
+ """
67
+ return gr.HTML(script)
68
+
69
+
70
+ css = """"""
71
+
72
+ with gr.Blocks(css=css) as myface:
73
+ make_dropdown_searchable("model_dropdown")
74
 
75
  with gr.Row():
76
  with gr.Row():