Mrchuw xp3857 commited on
Commit
ebb703c
0 Parent(s):

Duplicate from xp3857/text-to-image

Browse files

Co-authored-by: xp3857 <[email protected]>

Files changed (5) hide show
  1. .gitattributes +34 -0
  2. README.md +13 -0
  3. app.py +109 -0
  4. css.css +113 -0
  5. style.css +113 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Text To Image
3
+ emoji: 🌖
4
+ colorFrom: gray
5
+ colorTo: purple
6
+ sdk: gradio
7
+ sdk_version: 3.20.0
8
+ app_file: app.py
9
+ pinned: false
10
+ duplicated_from: xp3857/text-to-image
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import requests
4
+ import random
5
+ import time
6
+ name2 = "runwayml/stable-diffusion-v1-5"
7
+
8
+ models=[
9
+ gr.Interface.load(f"models/{name2}"),
10
+ gr.Interface.load(f"models/{name2}"),
11
+ gr.Interface.load(f"models/{name2}"),
12
+ gr.Interface.load(f"models/{name2}"),
13
+ gr.Interface.load(f"models/{name2}"),
14
+ gr.Interface.load(f"models/{name2}"),
15
+ gr.Interface.load(f"models/{name2}"),
16
+ gr.Interface.load(f"models/{name2}"),
17
+ gr.Interface.load(f"models/{name2}"),
18
+ gr.Interface.load(f"models/{name2}"),
19
+ gr.Interface.load(f"models/{name2}"),
20
+ gr.Interface.load(f"models/{name2}"),
21
+ gr.Interface.load(f"models/{name2}"),
22
+ gr.Interface.load(f"models/{name2}"),
23
+ gr.Interface.load(f"models/{name2}"),
24
+ gr.Interface.load(f"models/{name2}"),
25
+ gr.Interface.load(f"models/{name2}"),
26
+ gr.Interface.load(f"models/{name2}"),
27
+ gr.Interface.load(f"models/{name2}"),
28
+ gr.Interface.load(f"models/{name2}"),
29
+ ]
30
+ #o = os.getenv("P")
31
+ o = "V"
32
+
33
+ m_out = ("""
34
+ <div id="restart">
35
+ <h3 id="head">Loading Time Limit Reached.</h3><br>
36
+ <h4 id="cont">Please choose a Simpler Prompt, or <b>Upgrade</b> for faster loading.</h4>
37
+ </div>
38
+ """)
39
+ loading=("""
40
+ <div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>""")
41
+ def ac():
42
+ def clear():
43
+ return gr.update(value=0),gr.update(value=0)
44
+ def start():
45
+ stamp = time.time()
46
+ return gr.update(value=stamp),gr.update(value=0)
47
+ def end(stamp):
48
+ ts = stamp + 120
49
+ ti = time.time()
50
+ if ti > ts and stamp != 0:
51
+ return gr.update(value=1),gr.HTML.update(f"{m_out}",visible=True)
52
+ else:
53
+ return gr.update(value=0),None
54
+ def im_fn(put,fac="",h=None):
55
+ try:
56
+ if h == o:
57
+ put = f"{put}{fac}"
58
+ fac = f"{fac} "
59
+ rn = random.randint(0, 19)
60
+ model=models[rn]
61
+ return model(put),fac
62
+ elif h != o:
63
+ return(None,None)
64
+ except Exception:
65
+ return None, None
66
+ def cl_fac():
67
+ return "",gr.HTML.update(f"{loading}")
68
+ with gr.Blocks() as b:
69
+ with gr.Row():
70
+ with gr.Column():
71
+ put = gr.Textbox()
72
+ with gr.Column():
73
+ with gr.Row():
74
+ btn1 = gr.Button("Run")
75
+ btn2 = gr.Button("Clear")
76
+ message=gr.HTML("<div></div>")
77
+ message2=gr.HTML("",visible=False)
78
+
79
+ with gr.Row():
80
+ out1 = gr.Image()
81
+ out2 = gr.Image()
82
+ with gr.Row():
83
+ out3 = gr.Image()
84
+ out4 = gr.Image()
85
+
86
+ with gr.Row(visible=False):
87
+ h=gr.Textbox(value="V")
88
+ t_state=gr.Number()
89
+ t_switch=gr.Textbox(value=0)
90
+ def clear_all():
91
+ return "",None,None,None,None,None,None,1,gr.HTML.update("<div></div>")
92
+ fac_b = gr.Textbox(value="",visible=False)
93
+
94
+ def noth():
95
+ return gr.HTML.update("<div></div>")
96
+ #a1=btn1.click(noth,None,btn1,every=1)
97
+ btn1.click(cl_fac,None,[fac_b,message],show_progress=False)
98
+ b1=btn1.click(start,None,[t_state,t_switch],show_progress=True)
99
+ sta = t_state.change(end,t_state,[t_switch,message2],every=1,show_progress=True)
100
+ b2=btn1.click(im_fn,[put,fac_b,h],[out1,fac_b], show_progress=True)
101
+ b3=out1.change(im_fn,[put,fac_b,h],[out2,fac_b], show_progress=True)
102
+ b4=out2.change(im_fn,[put,fac_b,h],[out3,fac_b], show_progress=True)
103
+ b5=out3.change(im_fn,[put,fac_b,h],[out4,fac_b], show_progress=True)
104
+ b6=out4.change(noth,None,message, show_progress=False)
105
+ swi=t_switch.change(clear,None,[t_switch,fac_b], cancels=[sta,b2,b3,b4,b5],show_progress=False)
106
+ #btn2.click(noth,None,message,cancels=[b1,sta,b2,b3,b4,b5,swi],show_progress=False)
107
+ btn2.click(clear_all, None,[fac_b,put,out1,out2,out3,out4,t_state,t_switch,message],cancels=[b1,sta,b2,b3,b4,b5,swi],show_progress=False)
108
+ b.queue(concurrency_count=100).launch(show_api=False)
109
+ ac()
css.css ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .app.svelte-p7tiy3.svelte-p7tiy3{
2
+ background:None;
3
+ }
4
+ .unpadded_box.large.svelte-1vhybi6{
5
+ background:#6fbcffa8;
6
+ min-height:100%;
7
+ }
8
+ span.svelte-1l2rj76{
9
+ color:white;!important;
10
+ }
11
+ div.svelte-1fwqiwq .block{
12
+ background:#4d8df1;
13
+ }
14
+ .lg.svelte-1h4gtph{
15
+ background:#4d8df1;
16
+ color:white;
17
+ height:100px;
18
+ }
19
+ #restart{
20
+ position: relative;
21
+ font-family: "Poppins",sans-serif;
22
+ text-align: center;
23
+ border-radius: 8px;
24
+ background: #0063f787;
25
+ border-style: solid;
26
+ border-width: 1px;
27
+ border-color: #ffffff;
28
+ width: 100%;
29
+ height: 50%;
30
+ max-height: 200px;
31
+ padding: 0px 10px;
32
+ transform: translate(-50%,0%);
33
+ left: 50%;
34
+ }
35
+ #head{
36
+ color:white;
37
+ margin-top:15px;
38
+ margin-bottom:5px;
39
+ }
40
+ #cont{
41
+ color: white;
42
+ margin-top: 5px;
43
+ margin-bottom: 15px;
44
+ font-size: 1.1rem;
45
+ }
46
+
47
+ .lds-ellipsis {
48
+ display: inline-block;
49
+ position: relative;
50
+ width: 80px;
51
+ height: 80px;
52
+
53
+ }
54
+ .lds-ellipsis div {
55
+ position: absolute;
56
+ z-index:199999;
57
+
58
+ top: 33px;
59
+ width: 13px;
60
+ height: 13px;
61
+ border-radius: 50%;
62
+ background: blue;
63
+ animation-timing-function: cubic-bezier(0, 1, 1, 0);
64
+ }
65
+ .lds-ellipsis div:nth-child(1) {
66
+ left: 8px;
67
+ animation: lds-ellipsis1 0.6s infinite;
68
+ }
69
+ .lds-ellipsis div:nth-child(2) {
70
+ left: 8px;
71
+ animation: lds-ellipsis2 0.6s infinite;
72
+ }
73
+ .lds-ellipsis div:nth-child(3) {
74
+ left: 32px;
75
+ animation: lds-ellipsis2 0.6s infinite;
76
+ }
77
+ .lds-ellipsis div:nth-child(4) {
78
+ left: 56px;
79
+ animation: lds-ellipsis3 0.6s infinite;
80
+ }
81
+ @keyframes lds-ellipsis1 {
82
+ 0% {
83
+ transform: scale(0);
84
+ }
85
+ 100% {
86
+ transform: scale(1);
87
+ }
88
+ }
89
+ @keyframes lds-ellipsis3 {
90
+ 0% {
91
+ transform: scale(1);
92
+ }
93
+ 100% {
94
+ transform: scale(0);
95
+ }frames lds-ellipsis2 {
96
+ 0% {
97
+ transform: translate(0, 0);
98
+ }
99
+ 100% {
100
+ transform: translate(24px, 0);
101
+ }
102
+ }
103
+
104
+ }
105
+ @keyframes lds-ellipsis2 {
106
+ 0% {
107
+ transform: translate(0, 0);
108
+ }
109
+ 100% {
110
+ transform: translate(24px, 0);
111
+ }
112
+ }
113
+
style.css ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .app.svelte-p7tiy3.svelte-p7tiy3{
2
+ background:None;
3
+ }
4
+ .unpadded_box.large.svelte-1vhybi6{
5
+ background:None6fbcffa8;
6
+ min-height:100%;
7
+ }
8
+ span.svelte-1l2rj76{
9
+ color:white;!important;
10
+ }
11
+ div.svelte-1fwqiwq .block{
12
+ background:None4d8df1;
13
+ }
14
+ .lg.svelte-1h4gtph{
15
+ background:None4d8df1;
16
+ color:white;
17
+ height:100px;
18
+ }
19
+ #restart{
20
+ position: relative;
21
+ font-family: "Poppins",sans-serif;
22
+ text-align: center;
23
+ border-radius: 8px;
24
+ background: #0063f787;
25
+ border-style: solid;
26
+ border-width: 1px;
27
+ border-color: #ffffff;
28
+ width: 100%;
29
+ height: 50%;
30
+ max-height: 200px;
31
+ padding: 0px 10px;
32
+ transform: translate(-50%,0%);
33
+ left: 50%;
34
+ }
35
+ #head{
36
+ color:white;
37
+ margin-top:15px;
38
+ margin-bottom:5px;
39
+ }
40
+ #cont{
41
+ color: white;
42
+ margin-top: 5px;
43
+ margin-bottom: 15px;
44
+ font-size: 1.1rem;
45
+ }
46
+
47
+ .lds-ellipsis {
48
+ display: inline-block;
49
+ position: relative;
50
+ width: 80px;
51
+ height: 80px;
52
+
53
+ }
54
+ .lds-ellipsis div {
55
+ position: absolute;
56
+ z-index:199999;
57
+
58
+ top: 33px;
59
+ width: 13px;
60
+ height: 13px;
61
+ border-radius: 50%;
62
+ background: blue;
63
+ animation-timing-function: cubic-bezier(0, 1, 1, 0);
64
+ }
65
+ .lds-ellipsis div:nth-child(1) {
66
+ left: 8px;
67
+ animation: lds-ellipsis1 0.6s infinite;
68
+ }
69
+ .lds-ellipsis div:nth-child(2) {
70
+ left: 8px;
71
+ animation: lds-ellipsis2 0.6s infinite;
72
+ }
73
+ .lds-ellipsis div:nth-child(3) {
74
+ left: 32px;
75
+ animation: lds-ellipsis2 0.6s infinite;
76
+ }
77
+ .lds-ellipsis div:nth-child(4) {
78
+ left: 56px;
79
+ animation: lds-ellipsis3 0.6s infinite;
80
+ }
81
+ @keyframes lds-ellipsis1 {
82
+ 0% {
83
+ transform: scale(0);
84
+ }
85
+ 100% {
86
+ transform: scale(1);
87
+ }
88
+ }
89
+ @keyframes lds-ellipsis3 {
90
+ 0% {
91
+ transform: scale(1);
92
+ }
93
+ 100% {
94
+ transform: scale(0);
95
+ }frames lds-ellipsis2 {
96
+ 0% {
97
+ transform: translate(0, 0);
98
+ }
99
+ 100% {
100
+ transform: translate(24px, 0);
101
+ }
102
+ }
103
+
104
+ }
105
+ @keyframes lds-ellipsis2 {
106
+ 0% {
107
+ transform: translate(0, 0);
108
+ }
109
+ 100% {
110
+ transform: translate(24px, 0);
111
+ }
112
+ }
113
+