xyplon commited on
Commit
1d61a69
·
verified ·
1 Parent(s): 4344c7b

Delete text-to-image-models-playground

Browse files
text-to-image-models-playground/.gitattributes DELETED
@@ -1,35 +0,0 @@
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
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
text-to-image-models-playground/README.md DELETED
@@ -1,10 +0,0 @@
1
- ---
2
- title: Text To Image Models Playground
3
- emoji: 🏢
4
- colorFrom: purple
5
- colorTo: pink
6
- sdk: docker
7
- pinned: false
8
- ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
text-to-image-models-playground/app.py DELETED
@@ -1,53 +0,0 @@
1
- from flask import Flask, render_template,request,jsonify,Response
2
- import os
3
- import json
4
- from flask_cors import CORS
5
- import time
6
- from flask_limiter import Limiter
7
- from flask_limiter.util import get_remote_address
8
- import requests
9
- app = Flask(__name__)
10
- CORS(app)
11
-
12
- limiter = Limiter(
13
- key_func=get_remote_address,
14
- app=app,
15
- default_limits=["2000 per day", "500 per hour"]
16
- )
17
-
18
- @app.route("/")
19
- def index():
20
- return render_template('models.html')
21
-
22
-
23
- @app.route('/gen', methods=['POST'])
24
- @limiter.limit("8 per minute")
25
- def Hf():
26
- prompt = request.json.get('prompt', '')
27
- negative = request.json.get('negative', '')
28
- steps = request.json.get('steps', 20)
29
- width = request.json.get('width',1024)
30
- height = request.json.get('height',1024)
31
- scale = request.json.get('scale',7)
32
- model = request.json.get('model','sd3')
33
- style = request.json.get('style', 'Cinematic')
34
- def Gen(prompt,negative,steps,width,height,scale,style,model):
35
- req = requests.post('https://xyplon-server.hf.space/hf/img/gen',headers={
36
- 'Authorization' : os.getenv('auth')
37
- },json={
38
- 'prompt': prompt,
39
- 'negative': negative,
40
- 'steps': steps,
41
- 'width': width,
42
- 'height': height,
43
- 'scale': scale,
44
- 'model' : model,
45
- 'style': style
46
- })
47
- for chunk in req.iter_lines():
48
- yield f'{chunk.decode()}\n\n'
49
- return Response(Gen(prompt=prompt,negative=negative,steps=steps,width=width,height=height,scale=scale,style=style,model=model), mimetype="text/event-stream")
50
-
51
-
52
- if __name__ == "__main__":
53
- app.run(debug=True, host='0.0.0.0', port=7860)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
text-to-image-models-playground/static/models.js DELETED
@@ -1,184 +0,0 @@
1
- // DO NOT TRY TO COPY MY UI OR STYLR
2
-
3
-
4
- const div = document.getElementById('imshow');
5
- let width = 1024
6
- let height = 1024
7
- let btn = document.getElementById('btn')
8
- let prompt = document.getElementById('prompt')
9
- let negativePrompt = document.getElementById('negative-prompt')
10
- let model = 'rvx4'
11
- let style = 'Cinematic'
12
-
13
-
14
- const modelElement = document.getElementById('model');
15
- modelElement.addEventListener('change', function() {
16
- model = this.value
17
- if (model == "mobius") {
18
- document.getElementById('guidenceRange').value = 3
19
- document.getElementById('guidenceValue').innerText = 3;
20
- }
21
- if(model=="rvx4"){
22
- document.getElementById('guidenceRange').value = 4
23
- document.getElementById('guidenceValue').innerText = 4;
24
- }
25
- if(model=="sd3"){
26
- document.getElementById('guidenceRange').value = 5
27
- document.getElementById('guidenceValue').innerText = 5;
28
- }
29
- if(model=="animagine"){
30
- document.getElementById('guidenceRange').value = 7
31
- document.getElementById('guidenceValue').innerText = 7;
32
- }
33
- if(model=="sdflash"){
34
- document.getElementById('guidenceRange').value = 3
35
- document.getElementById('guidenceValue').innerText = 3;
36
- document.getElementById('stepValue').innerText = 8
37
-
38
- }
39
- });
40
-
41
- const ratioElement =document.getElementById('ratio')
42
- ratioElement.addEventListener('change',function(){
43
- ratio = this.value
44
- if(ratio == '1:1'){
45
- width = 1024;
46
- height = 1024;
47
- }
48
- else if(ratio == '16:9'){
49
- width = 1024;
50
- height = 576;
51
- }
52
- else if(ratio == "9:16"){
53
- width = 576
54
- height = 1024
55
- }
56
- else if(ratio=="1:2"){
57
- width = 544;
58
- height = 1088;
59
- }
60
- else if(ratio=='4:3'){
61
- width = 896;
62
- height = 672;
63
- }
64
- })
65
-
66
- const styleElement = document.getElementById('style')
67
- styleElement.addEventListener('change',function(){
68
- style = this.value
69
- })
70
-
71
- document.getElementById('stepsRange').addEventListener('input', function() {
72
-
73
- if(model=='sdflash' && Number(document.getElementById('stepValue').innerText)>16){
74
- document.getElementById('stepValue').innerText = 16
75
- }
76
- else {
77
- document.getElementById('stepValue').innerText = this.value;
78
- }
79
-
80
- }
81
- );
82
-
83
- document.getElementById('guidenceRange').addEventListener('input', function() {
84
- document.getElementById('guidenceValue').innerText = this.value;
85
- });
86
-
87
-
88
-
89
-
90
-
91
- function log(msg){
92
- console.log(msg)
93
- }
94
-
95
- let task = 0
96
- btn.onclick = async () => {
97
-
98
- const params = {
99
- 'prompt': prompt.value,
100
- 'negative': negativePrompt.value,
101
- "steps": Number(document.getElementById('stepValue').innerText),
102
- 'scale': Number(document.getElementById('guidenceValue').innerText),
103
- "width": Number(width),
104
- "height": Number(height),
105
- "model": model,
106
- 'style': style
107
- };
108
-
109
-
110
-
111
- async function generateImage(params) {
112
- let loader = document.createElement('div')
113
- loader.id = 'loader'
114
- if (div.firstChild!== loader) {
115
- div.insertBefore(loader, div.firstChild);
116
- }
117
- task+=1
118
- let text = document.createElement('p')
119
- text.style.color = 'white'
120
- let loaderImg = document.createElement('img')
121
- loaderImg.src = 'https://fumesai.web.app/load.gif'
122
- loader.append(loaderImg)
123
- text.innerText = ''
124
-
125
- try {
126
- const response = await fetch('/gen', {
127
- method: 'POST',
128
- headers: {
129
- 'Content-Type': 'application/json',
130
- 'Connection': 'keep-alive',
131
- },
132
- body: JSON.stringify(params)
133
- });
134
-
135
- if (!response.ok) {
136
-
137
- if(response.status==429){
138
- alert('too many requests! 4 concurrent jobs per minute is allowed')
139
- loader.parentNode.removeChild(loader);
140
- return
141
- }
142
- }
143
-
144
- const reader = response.body.getReader();
145
- const decoder = new TextDecoder();
146
- while (true) {
147
- const { done, value } = await reader.read();
148
- if (done) break;
149
-
150
- const chunk = decoder.decode(value, { stream: true });
151
- const lines = chunk.split('\n');
152
-
153
- for (const line of lines) {
154
- if (line.startsWith('data: ')) {
155
- const jsonChunk = JSON.parse(line.substring(6));
156
-
157
- if (jsonChunk.progress === 'done') {
158
-
159
- loader.parentNode.removeChild(loader);
160
- const img = document.createElement('img');
161
- if(jsonChunk.width==1024 && jsonChunk.height==576){
162
- img.id = 'lds'
163
- }
164
- img.src = jsonChunk.img;
165
- if (div.firstChild!== img) {
166
- div.insertBefore(img, div.firstChild);
167
- }
168
-
169
- } else {
170
- text.innerText = `${jsonChunk.progress}%`;
171
- loader.appendChild(text);
172
- }
173
- }
174
- }
175
- }
176
-
177
- } catch (error) {
178
- console.error(error);
179
- }
180
- }
181
- generateImage(params)
182
- generateImage(params)
183
- }
184
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
text-to-image-models-playground/templates/models.html DELETED
@@ -1,285 +0,0 @@
1
-
2
- <!DOCTYPE html>
3
- <html lang="en">
4
- <head>
5
- <meta charset="UTF-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>Stable Diffusion Models Demo</title>
8
- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
9
- <link href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@100&display=swap" rel="stylesheet" <meta
10
- charset="UTF-8">
11
- <style>
12
- body {
13
- background-color: #030303;
14
- color: #ffffff;
15
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
16
- width: 100%;
17
- overflow-x: hidden;
18
-
19
- }
20
- html,body{
21
- overflow-x: hidden;
22
- }
23
-
24
- .form-control,
25
- .form-select {
26
- background-color: #1a1a1a;
27
- color: #ffffff;
28
- border: none;
29
- border-radius: 0;
30
- }
31
-
32
-
33
-
34
- .form-control::placeholder {
35
- color: #d8d8d8;
36
- }
37
- .form-control:focus,
38
- .form-select:focus {
39
- outline: none;
40
- border-color: transparent;
41
- }
42
- .btn-primary {
43
- background: linear-gradient(155deg, rgb(0, 149, 249), #9D00FF, rgb(255, 0, 43));
44
- border: none;
45
- }
46
- .btn-primary:hover {
47
- background: linear-gradient(145deg, #00ffab, rgb(255, 0, 43));
48
- }
49
- .btn-primary:focus {
50
- box-shadow: none;
51
- }
52
- #prompt{
53
- background-color: #030303;
54
- outline: 4px solid #030303;
55
- }
56
-
57
- #negative-prompt{
58
- background-color: #1b1b1b;
59
- border: 1px solid #141414;
60
- border-radius: 10px;
61
- outline: 3px solid #141414;
62
- }
63
- #modelLabel{
64
- background: linear-gradient(155deg, rgb(0, 249, 228), #d400ff, rgb(255, 0, 212));
65
- }
66
- #ratioLabel{
67
- background: linear-gradient(155deg, rgb(0, 199, 249), #9D00FF, rgb(255, 0, 119));
68
- }
69
- #styleLabel{
70
- background: linear-gradient(155deg, rgb(0, 249, 249), #a200ff, rgb(255, 0, 191));
71
- }
72
- .form-range::-webkit-slider-runnable-track {
73
- background-color: #1d1d1d;
74
- }
75
-
76
- .form-range::-moz-range-track {
77
- background-color: #1d1d1d;
78
- }
79
-
80
- .form-range::-ms-track {
81
- background-color: #1d1d1d;
82
- }
83
- .form-range::-webkit-slider-thumb {
84
- background: linear-gradient(155deg, rgb(0, 249, 228), #d400ff, rgb(255, 0, 34));;
85
- }
86
-
87
- .form-range::-moz-range-thumb {
88
- background: gray;
89
- }
90
-
91
- .form-range::-ms-thumb {
92
- background: gray;
93
- }
94
- .input-group-div1{
95
- background-color: #030303;
96
- padding: 5px;
97
-
98
- background: linear-gradient(rgb(0, 0, 0), black) padding-box,
99
- linear-gradient(to left, rgb(255, 1, 98), rgb(175, 2, 255)) border-box;
100
- border: 1.5px solid transparent;
101
- border-radius: 7px;
102
- }
103
- .input-group-div{
104
- padding: 5px;
105
- background: #131313;
106
- border-radius: 10px;
107
- }
108
- .input-group-div1:hover{
109
- background: linear-gradient(rgb(0, 0, 0), black) padding-box,
110
- linear-gradient(to left, rgb(204, 1, 255), rgb(255, 2, 44)) border-box;
111
-
112
-
113
- }
114
-
115
- @keyframes colorChange {
116
- 0% {
117
- color: rgb(7, 205, 240) ;
118
- }
119
- 25% {
120
- color: rgb(214, 12, 130);
121
- }
122
- 50% {
123
- color: #09cfe9;
124
- }
125
- 75% {
126
- color: #e2335f;
127
- }
128
- 100% {
129
- color: rgb(240, 4, 102);
130
- }
131
- }
132
- .col-12 p{
133
- animation: colorChange 10s infinite;
134
- font-family: 'Barlow Condensed';
135
- font-size: 25px;
136
- font-weight: bold;
137
- }
138
- #imshow {
139
- display: flex;
140
- flex-wrap: wrap;
141
- gap: 10px;
142
- justify-content: center;
143
- align-items: center;
144
- }
145
- #loader{
146
- margin: auto;
147
- width: fit-content;
148
- text-align: center;
149
-
150
-
151
-
152
- }
153
- #cont4{
154
- max-width: 95vw;
155
- }
156
- #imshow img{
157
- max-width: 280px;
158
- margin: 0;
159
- padding: 0;
160
- }
161
- #lds{
162
- max-width: 350px;
163
- }
164
- @media screen and (max-width: 600px) {
165
- #imshow{
166
- justify-content: center;
167
- align-items: center;
168
- }
169
- #imshow img{
170
- max-width: 320px;
171
- }
172
- }
173
-
174
- </style>
175
- </head>
176
- <body>
177
-
178
- <div class="container mt-4">
179
-
180
- <div class="row mt-4">
181
- <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 mb-3">
182
- <div class="input-group-div1">
183
- <input type="text" class="form-control" id="prompt" placeholder="Prompt" autocomplete="off">
184
- </div>
185
- </div>
186
- <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12 mb-3">
187
- <div class="input-group-div">
188
- <input type="text" class="form-control" id="negative-prompt" placeholder="Negative Prompt" autocomplete="off" >
189
- </div>
190
- </div>
191
- <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12 mb-3">
192
- <div class="input-group">
193
- <label class="input-group-text me-3" for="model" id="modelLabel" style="background-color: #1d1d1d;color: white;border: none;">Model</label>
194
- <select class="form-select" id="model" aria-label="Model Select">
195
- <option value="rvx4" selected>real vision xl 4</option>
196
- <option value="mobius">Mobius</option>
197
- <option value="animagine">Animagine xl 3.1</option>
198
- <option value="sd3">Stable Diffusion 3</option>
199
- <option value="sdflash">SDXL Flash</option>
200
-
201
- </select>
202
- </div>
203
- </div>
204
- <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12 mb-3">
205
- <div class="input-group">
206
-
207
- <label class="input-group-text me-3" id="ratioLabel" for="ratio" style="background-color: #1d1d1d;color: white;border: none;margin: 0;">Image Ratio</label>
208
-
209
-
210
- <select class="form-select" id="ratio" aria-label="Ratio Select">
211
- <option selected value="1:1">1:1 (Square)</option>
212
- <option value="16:9">16:9 (Landscape)</option>
213
- <option value="9:16">9:16 (Portrait)</option>
214
- <option value="1:2">1:2</option>
215
- <option value="4:3">4:3</option>
216
- </select>
217
- </div>
218
- </div>
219
- <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12 mb-3">
220
- <div class="input-group">
221
- <label class="input-group-text me-3" for="style" style="background-color: #1d1d1d;color: white;border: none;" id="styleLabel">Style:</label>
222
- <select class="form-select" id="style" aria-label="Style Select">
223
- <option value="Cinematic" name="style">Cinematic</option>
224
- <option value="Photography" name="style">Photography</option>
225
- <option value="Anime" name="style">Anime</option>
226
- <option value="Film" name="style">Film</option>
227
- <option value="Creative" name="style">Creative</option>
228
- <option value="Digital" name="style">Digital Art</option>
229
- <option value="3d" name="style">3D Model</option>
230
- <option value="No" name="style">No Style</option>
231
- </select>
232
- </div>
233
- </div>
234
- <div id="ranges" style="display: flex; gap: 15px; flex-wrap: wrap;">
235
- <div class="stepsRange" style="display: flex;gap: 10px;">
236
- <label for="stepsRange" class="form-label" style="background-color: #1d1d1d;color: white;border: none; padding-left: 10px; padding-right: 10px; padding-top: 6px; padding-bottom: 6px;">Steps: <p style="display: inline;" id="stepValue">30</p></label>
237
- <input type="range" class="form-range" id="stepsRange" style="width: 200px;padding-top: 12px;" min="4" max="100" value="30">
238
- </div>
239
-
240
- <div class="guidenceRange" style="display: flex;gap: 10px;">
241
- <label for="stepsRange" class="form-label" style="background-color: #1d1d1d;color: white;border: none; padding-left: 10px; padding-right: 10px; padding-top: 6px; padding-bottom: 6px;">Guidence Scale: <p style="display: inline;" id="guidenceValue">7</p></label>
242
- <input type="range" class="form-range" id="guidenceRange" style="width: 200px; padding-top: 12px; " min="2" max="20" value="4">
243
- </div>
244
- </div>
245
-
246
-
247
- <div class="col-12 text-center mt-4">
248
- <button type="button" class="btn btn-primary" id="btn">Generate Image ( Ctr + Enter) </button>
249
- </div>
250
- </div>
251
-
252
- <div class="container mt-4" id="cont4">
253
- <div id="imshow" >
254
-
255
-
256
- </div>
257
- </div>
258
-
259
-
260
- </div>
261
-
262
-
263
- </div>
264
-
265
-
266
- <script>
267
- document.getElementById('prompt').addEventListener('mouseover', () => {
268
- document.getElementById('prompt').placeholder = 'Enter Your Prompt';
269
- });
270
- document.getElementById('prompt').addEventListener('mouseout', () => {
271
- document.getElementById('prompt').placeholder = 'Prompt';
272
- });
273
- document.getElementById('prompt').addEventListener('input', function() {
274
- this.style.color = 'white';
275
- });
276
- document.getElementById('negative-prompt').addEventListener('input', function() {
277
- this.style.color = 'skyblue';
278
- });
279
-
280
- </script>
281
-
282
- <script src="{{ url_for('static', filename='models.js') }}"></script>
283
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
284
- </body>
285
- </html>