Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -138,40 +138,24 @@ def load_gallery_sorted(gallery,id):
|
|
| 138 |
for c in sorted(cache_image[f"{id}"], key=itemgetter(1)):
|
| 139 |
gallery=add_gallery(c[0],c[1],gallery)
|
| 140 |
return gallery
|
| 141 |
-
def load_gallery_actu(gallery,id):
|
| 142 |
-
gallery = reset_gallery(gallery)
|
| 143 |
-
for c in cache_image_actu[f"{id}"]:
|
| 144 |
-
gallery=add_gallery(c[0],c[1],gallery)
|
| 145 |
-
return gallery
|
| 146 |
|
| 147 |
def add_cache_image(image, model_str,id,cache_image=cache_image):
|
| 148 |
if image is not None:
|
| 149 |
cache_image[f"{id}"].append((image,model_str))
|
| 150 |
#cache_image=sorted(cache_image, key=itemgetter(1))
|
| 151 |
return
|
| 152 |
-
def add_cache_image_actu(image, model_str,id,cache_image_actu=cache_image_actu):
|
| 153 |
-
if image is not None:
|
| 154 |
-
bisect.insort(cache_image_actu[f"{id}"],(image, model_str), key=itemgetter(1))
|
| 155 |
-
#cache_image_actu=sorted(cache_image_actu, key=itemgetter(1))
|
| 156 |
-
return
|
| 157 |
def reset_cache_image(id,cache_image=cache_image):
|
| 158 |
cache_image[f"{id}"].clear()
|
| 159 |
return
|
| 160 |
-
def
|
| 161 |
-
cache_image_actu[f"{id}"].clear()
|
| 162 |
-
return
|
| 163 |
-
def reset_cache_image_all_sessions(cache_image=cache_image,cache_image_actu=cache_image_actu):
|
| 164 |
for key, listT in cache_image.items():
|
| 165 |
listT.clear()
|
| 166 |
-
for key, listT in cache_image_actu.items():
|
| 167 |
-
listT.clear()
|
| 168 |
return
|
| 169 |
|
| 170 |
def set_session(id):
|
| 171 |
if id==0:
|
| 172 |
randTemp=randint(1,MAX_SEED)
|
| 173 |
cache_image[f"{randTemp}"]=[]
|
| 174 |
-
cache_image_actu[f"{randTemp}"]=[]
|
| 175 |
return gr.Number(visible=False,value=randTemp)
|
| 176 |
else :
|
| 177 |
return id
|
|
@@ -402,6 +386,7 @@ def make_me():
|
|
| 402 |
outputs=[]
|
| 403 |
for i in len(nb_req_simult):
|
| 404 |
outputs.append(gr.Image(None,interactive=False,render=False))
|
|
|
|
| 405 |
|
| 406 |
|
| 407 |
|
|
@@ -414,7 +399,7 @@ def make_me():
|
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
-
gen_button.click(set_session, id_session, id_session)
|
| 418 |
|
| 419 |
|
| 420 |
js_code = """
|
|
|
|
| 138 |
for c in sorted(cache_image[f"{id}"], key=itemgetter(1)):
|
| 139 |
gallery=add_gallery(c[0],c[1],gallery)
|
| 140 |
return gallery
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
def add_cache_image(image, model_str,id,cache_image=cache_image):
|
| 143 |
if image is not None:
|
| 144 |
cache_image[f"{id}"].append((image,model_str))
|
| 145 |
#cache_image=sorted(cache_image, key=itemgetter(1))
|
| 146 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
def reset_cache_image(id,cache_image=cache_image):
|
| 148 |
cache_image[f"{id}"].clear()
|
| 149 |
return
|
| 150 |
+
def reset_cache_image_all_sessions(cache_image=cache_image):
|
|
|
|
|
|
|
|
|
|
| 151 |
for key, listT in cache_image.items():
|
| 152 |
listT.clear()
|
|
|
|
|
|
|
| 153 |
return
|
| 154 |
|
| 155 |
def set_session(id):
|
| 156 |
if id==0:
|
| 157 |
randTemp=randint(1,MAX_SEED)
|
| 158 |
cache_image[f"{randTemp}"]=[]
|
|
|
|
| 159 |
return gr.Number(visible=False,value=randTemp)
|
| 160 |
else :
|
| 161 |
return id
|
|
|
|
| 386 |
outputs=[]
|
| 387 |
for i in len(nb_req_simult):
|
| 388 |
outputs.append(gr.Image(None,interactive=False,render=False))
|
| 389 |
+
|
| 390 |
|
| 391 |
|
| 392 |
|
|
|
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
+
#gen_button.click(set_session, id_session, id_session)
|
| 403 |
|
| 404 |
|
| 405 |
js_code = """
|