File size: 5,063 Bytes
b6b08f6
af2f25b
b593cfa
477a5c9
7416ccf
b593cfa
 
f97094c
b593cfa
f97094c
477a5c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b593cfa
 
bd88d47
370ecfb
 
d0371fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bd88d47
d0371fc
 
bd88d47
d0371fc
 
 
 
 
 
 
 
 
 
 
 
9f876f8
bd88d47
d0371fc
 
 
 
 
 
 
 
 
 
 
 
 
bd88d47
d0371fc
 
bd88d47
d0371fc
 
 
 
 
bd88d47
d0371fc
 
 
 
 
 
 
 
 
 
 
 
 
370ecfb
9b182cf
d0371fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7dd61d0
 
d0371fc
 
 
 
9b182cf
bd88d47
 
370ecfb
bd88d47
 
a2ffcba
510f059
f0174d9
4b9f915
ebad00c
4b9f915
b593cfa
4b9f915
bd88d47
4b9f915
 
59afa4a
370ecfb
4b9f915
59afa4a
bd88d47
b593cfa
 
a2ffcba
b593cfa
 
 
 
 
a2ffcba
b593cfa
184a373
b593cfa
 
370ecfb
184a373
 
 
b6eb1a4
 
184a373
b6eb1a4
184a373
 
f0174d9
b593cfa
4b9f915
 
b593cfa
184a373
b593cfa
 
 
bd88d47
b593cfa
15fe5dd
 
 
 
b593cfa
dc619c2
b593cfa
8646ee7
af2f25b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import gradio as gr
import os
import requests
import random
import time
r = requests.get(f'https://huggingface.co/spaces/xp3857/text-to-image/raw/main/css.css') 
css = r.text
name2 = "runwayml/stable-diffusion-v1-5"

model = gr.Interface.load(f"models/{name2}")
models=[
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
    gr.Interface.load(f"models/{name2}"),
]
#o = os.getenv("P")
o = "V"

t_out = ("""
<head>
  
  <!--====== Design by foolishdeveloper.com =====-->
  
  
    <title>Automatic Popup</title>
    <!--Google Fonts-->
    <link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
    <!--Stylesheets-->
    <style media="screen">
      *,
*:before,
*:after{
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}
body{
    background-color: #0855ae;
}
.popup{
    background-color: #ffffff;
    width: 420px;
    padding: 30px 40px;
    position: absolute;
    transform: translate(-50%,-50%);
    left: 50%;
    top: 50%;
    border-radius: 8px;
    font-family: "Poppins",sans-serif;
    display: none; 
    text-align: center;
    z-index:1999999;
}
.popup button{
    display: block;
    margin:  0 0 20px auto;
    background-color: transparent;
    font-size: 30px;
    color: #ffffff;
    background: #03549a;
    border-radius: 100%;
    width: 40px;
    height: 40px;
    border: none;
    outline: none;
    cursor: pointer;
}
.popup h2{
  margin-top: -20px;
}
.popup p{
    font-size: 14px;
    text-align: justify;
    margin: 20px 0;
    line-height: 25px;
}
a{
    display: block;
    width: 150px;
    position: relative;
    margin: 10px auto;
    text-align: center;
    background-color: #0f72e5;
    border-radius: 20px;
    color: #ffffff;
    text-decoration: none;
    padding: 8px 0;
}
    </style>
</head>

    <div class="popup">
        <button id="close">&times;</button>
        <h2>Automatic Pop-Up</h2>
        <p>
            Time Out!
        </p>
        <a href="#">Let's Go</a>
    </div>
    <!--Script-->
    <script type="text/javascript">
window.addEventListener("load", function(){
    setTimeout(
        function open(event){
            document.querySelector(".popup").style.display = "block";
        },
        2000 
    )
});


document.querySelector("#close").addEventListener("click", function(){
    document.querySelector(".popup").style.display = "none";
});
    </script>



""")


def ac():
    def clear():
        return gr.update(value=0),gr.update(value=0)
    def start():
        print ("start")
        stamp = time.time()
        return gr.update(value=stamp),gr.update(value=0)
    def end(stamp):
        ts = stamp + 10
        ti = time.time()
        if ti > ts and stamp != 0:
            print("Cancelling")
            return gr.update(value=1),gr.HTML.update(f"{t_out}", visible=True)
        else:
            print("Passing")
            return gr.update(value=0),None
    
    def im_fn(put,fac="",h=None):
        if h == o:
            put = f"{put}{fac}"
            fac = f"{fac} "
            rn = random.randint(0, 19)
            model=models[rn]
            return model(put),fac
        elif h != o:
            return(None,None)
    def cl_fac():
        return ""
    with gr.Blocks(css=css) as b:
        message=gr.HTML("", visible=False)
        with gr.Row():
            put = gr.Textbox()            
            btn1 = gr.Button()
        with gr.Row():
            out1 = gr.Image()
            out2 = gr.Image()
        with gr.Row():
            out3 = gr.Image()
            out4 = gr.Image()
        with gr.Row(visible=False):
            h=gr.Textbox(value="V")
            t_state=gr.Number()
            t_switch=gr.Textbox(value=0)
            
        fac_b = gr.Textbox(value="",visible=False)
        btn1.click(cl_fac,None,fac_b)

        b1=btn1.click(start,None,[t_state,t_switch])
        sta = t_state.change(end,t_state,[t_switch,message],every=1)

        b2=btn1.click(im_fn,[put,fac_b,h],[out1,fac_b])
        b3=out1.change(im_fn,[put,fac_b,h],[out2,fac_b])        
        b4=out2.change(im_fn,[put,fac_b,h],[out3,fac_b])        
        b5=out3.change(im_fn,[put,fac_b,h],[out4,fac_b])  

        t_switch.change(clear,None,[t_switch,fac_b], cancels=[sta,b2,b3,b4,b5])
        
    b.queue(concurrency_count=100).launch(show_api=False)
ac()