Spaces:
Sleeping
Sleeping
github-actions commited on
Commit ·
8682ef8
1
Parent(s): e915cc7
Update for version v7.1.13
Browse files8 unmodified lines9101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354552 unmodified lines5859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351368 unmodified linesd='PATH_INFO'c='embykeeperweb'b='embykeeper'W='/ek'V=NoneU='install'T='pip'S='-m'R=setQ=ExceptionL='CONTENT_TYPE'G=FalseD=intB=printA=Trueimport eventlet as HH.monkey_patch()import os as C,sys as I,tempfile as m,subprocess as E,shutil as Ffrom pathlib import Pathimport threading as Xfrom appdirs import user_data_dir as nimport socketio as M,eventlet as H,requests as YJ='7.1.12'o=Path(n(b))N=o/'hf'/'version'def p():try:N.mkdir(parents=A,exist_ok=A);M=N/f"emby-keeper-{J}";H=N/f"emby-keeper-{J}.tar.gz"if M.exists():B(f"Using cached version from {M}",flush=A);return AK=m.mkdtemp();B('Downloading EK...',flush=A);D=C.path.join(K,'embykeeper.tar.gz')if H.exists():B(f"Using cached tarball from {H}",flush=A);F.copy2(H,D)else:O=f"https://github.com/emby-keeper/emby-keeper/archive/refs/tags/v{J}.tar.gz";E.run(['wget','-q',O,'-O',D],check=A);F.copy2(D,H)E.run(['tar','xf',D,'-C',K],check=A);C.remove(D);L=C.path.join(K,f"emby-keeper-{J}");B('Obfuscating code...',flush=A)if not q(L):raise Q('Obfuscation failed')B('Installing dependencies...',flush=A);E.run([I.executable,S,T,U,'-r',C.path.join(L,'requirements.txt')],check=A);E.run([I.executable,S,T,U,L],check=A);F.copytree(L,M,dirs_exist_ok=A);F.rmtree(K);return Aexcept Q as P:B(f"Error setting up EK: {P}",flush=A);return Gdef q(package_path):P='dist';O='pyarmor';J=package_pathtry:E.run([I.executable,S,T,U,O],check=A)for K in[b,c]:D=C.path.join(J,K)if not C.path.exists(D):B(f"Package directory not found: {D}",flush=A);continueB(f"Obfuscating {K}...",flush=A);E.run([O,'gen','--recursive','--output',C.path.join(J,P),D],check=A);H=C.path.join(J,P)if C.path.exists(H):for M in C.listdir(H):L=C.path.join(H,M);N=C.path.join(D,M)2 unmodified linesF.rmtree(H)else:B(f"Dist directory not found after obfuscation for {K}",flush=A);return Greturn Aexcept Q as R:B(f"Error during obfuscation: {R}",flush=A);return Gdef O():with H.listen(('',0))as A:return A.getsockname()[1]def r():I='Prompt Generator v0.2(More tags)';H='Prompt Generator v0.1(Better quality)';import gradio as C,random as M;from time import time,ctimedef J(choice,num,artist):L='art by';J=choice;E=artist;C=num;N=time();B(ctime(N))if J==H:G=open('pr1.txt').read().splitlines()elif J==I:G=open('pr2.txt').read().splitlines()if D(C)<1 or D(C)>20:C=10if D(E)<0 or D(E)>40:E=2O=len(G);A=[];K=0while len(sorted(R(A),key=lambda d:A.index(d)))<D(C):F=M.choice(G)if F.startswith(L)and K<D(E):K+=1;A.append(F)elif not F.startswith(L):A.append(F)B(', '.join(R(A))+'\n\n');return', '.join(R(A))E=C.Blocks()with E:C.HTML('\n <div style="text-align: center; margin: 0 auto;">\n <div style="display: inline-flex;align-items: center;gap: 0.8rem;font-size: 1.75rem;">\n <h1 style="font-weight: 900; margin-bottom: 7px;margin-top:5px">\n Simple Prompt Generator v0.6 (Gradio Demo)\n </h1>\n </div>\n <p style="margin-bottom: 10px; font-size: 94%; line-height: 23px;">\n Simple prompt generation script for Midjourney, DALLe, Stable and Disco diffusion and etc neural networks. <br> <p>More examples in <a class=\'link-info\' href="https://github.com/WiNE-iNEFF/Simple_Prompt_Generator" target="_blank">Github</a> and <a class=\'link-info\' href="https://wine-ineff.github.io/Simple_Prompt_Generator/" target="_blank">Project site</a></p>\n </p>\n <center>\n <img style="display: inline-block, margin-right: 1%;" src=\'https://visitor-badge.laobi.icu/badge?page_id=WiNE-iNEFF.Simple_Prompt_Generator&left_color=red&right_color=green&left_text=Visitors\' alt=\'visitor badge\'>\n <img style="display: inline-block, margin-right: 1%;" src=\'https://visitor-badge.laobi.icu/badge?page_id=WiNE-iNEFF.HF_Simple_Prompt_Generator&left_color=red&right_color=green&left_text=Visitors\' alt=\'visitor badge\'>\n </center>\n </div>\n ')with C.Column():K=C.Radio([H,I],label='Model Variant',value=H);L=C.Number(value='10',label='Num of tag (MAX 20)',show_label=A);N=C.Number(value='2',label='Num of artist (Standart 2)',show_label=A);P=C.Textbox(lines=4,label='Generated Prompts')Q=C.Button('Generate');Q.click(fn=J,inputs=[K,L,N],outputs=P,concurrency_limit=4);C.HTML('\n <div class="footer">\n <div style=\'text-align: center;\'>Simple Prompt Generator by <a href=\'https://twitter.com/wine_ineff\' target=\'_blank\'>Artsem Holub (WiNE-iNEFF)</a><br>More information about this demo and script your can find in <a class=\'link-info\' href="https://github.com/WiNE-iNEFF/Simple_Prompt_Generator" target="_blank">Github</a> and <a class=\'link-info\' href="https://wine-ineff.github.io/Simple_Prompt_Generator/" target="_blank">Project site</a></div>\n </div>\n ')E.queue();F=O();B(f"Starting Gradio on port {F}",flush=A);E.launch(server_name='127.0.0.1',server_port=F,share=G);return Fdef s():N='disconnect';J='connect';C='/pty';E=M.Server(async_mode='eventlet');O=M.WSGIApp(E);F=M.Client();I={}@E.on(J,namespace=C)def R(sid,environ):B(f"Client connected: {sid}")if not F.connected:F.connect('http://127.0.0.1:7862',namespaces=[C])I[sid]=A@E.on(N,namespace=C)def S(sid):B(f"Client disconnected: {sid}");I.pop(sid,V)if not I:F.disconnect()@E.on('*',namespace=C)def T(event,sid,*D):A=eventif A not in[J,N]:B(f"Forward to ek: {A}");F.emit(A,*D,namespace=C)@F.on('*',namespace=C)def U(event,*D):A=eventif A not in[J,N]:B(f"Forward from ek: {A}");E.emit(A,*D,namespace=C)def Q(environ,start_response):B=environ;H=B[d]if H.startswith(W):I=f"http://127.0.0.1:{K}"else:I=f"http://127.0.0.1:{P}"O=f"{I}{H}";F={}for(J,Q)in B.items():if J.startswith(e):M=J[5:].replace('_','-').title()if M.lower()not in[f,g,h]:F[M]=QC=B.get(i);N=Vif C:C=D(C);N=B[j].read(C)if B.get(L):F[k]=B[L]E=Y.request(method=B[l],url=O,headers=F,data=N,stream=A,allow_redirects=G);start_response(f"{E.status_code} {E.reason}",list(E.headers.items()));return E.iter_content(chunk_size=4096)O.wsgi_app=Q;H.wsgi.server(H.listen(('',7860)),O)if __name__=='__main__':B('Setting up EK...',flush=A)if not p():B('Failed to setup EK!',flush=A);I.exit(1)P=O();K=O();B(f"Using ports - Gradio: {P}, EK: {K}",flush=A);Z=X.Thread(target=lambda:r());Z.daemon=A;Z.start();a=X.Thread(target=lambda:E.run([c,'--port',str(K),'--prefix',W,'--public']));a.daemon=A;a.start()def t(environ,start_response):B=environ;H=B[d]if H.startswith(W):I=f"http://127.0.0.1:{K}"else:I=f"http://127.0.0.1:{P}"O=f"{I}{H}";F={}for(J,Q)in B.items():if J.startswith(e):M=J[5:].replace('_','-').title()if M.lower()not in[f,g,h]:F[M]=QC=B.get(i);N=Vif C:C=D(C);N=B[j].read(C)if B.get(L):F[k]=B[L]E=Y.request(method=B[l],url=O,headers=F,data=N,stream=A,allow_redirects=G);start_response(f"{E.status_code} {E.reason}",list(E.headers.items()));return E.iter_content(chunk_size=4096)B('Starting proxy server on port 7860...',flush=A);s()8 unmodified lines9101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354552 unmodified lines5859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351368 unmodified linesd='PATH_INFO'c='embykeeperweb'b='embykeeper'V='/ek'U=NoneT='install'S='pip'R='-m'Q=setP=ExceptionM='CONTENT_TYPE'G=FalseD=intB=printA=Trueimport eventlet as HH.monkey_patch()import os as C,sys as J,tempfile as m,subprocess as E,shutil as Ffrom pathlib import Pathimport threading as Wfrom appdirs import user_data_dir as nimport socketio as N,eventlet as H,requests as XK='7.1.13'o=Path(n(b))O=o/'hf'/'version'def p():try:O.mkdir(parents=A,exist_ok=A);M=O/f"emby-keeper-{K}";H=O/f"emby-keeper-{K}.tar.gz"if M.exists():B(f"Using cached version from {M}",flush=A);return AI=m.mkdtemp();B('Downloading EK...',flush=A);D=C.path.join(I,'embykeeper.tar.gz')if H.exists():B(f"Using cached tarball from {H}",flush=A);F.copy2(H,D)else:N=f"https://github.com/emby-keeper/emby-keeper/archive/refs/tags/v{K}.tar.gz";E.run(['wget','-q',N,'-O',D],check=A);F.copy2(D,H)E.run(['tar','xf',D,'-C',I],check=A);C.remove(D);L=C.path.join(I,f"emby-keeper-{K}");B('Obfuscating code...',flush=A)if not q(L):raise P('Obfuscation failed')B('Installing dependencies...',flush=A);E.run([J.executable,R,S,T,'-r',C.path.join(L,'requirements.txt')],check=A);E.run([J.executable,R,S,T,L],check=A);F.copytree(L,M,dirs_exist_ok=A);F.rmtree(I);return Aexcept P as Q:B(f"Error setting up EK: {Q}",flush=A);return Gdef q(package_path):Q='dist';O='pyarmor';I=package_pathtry:E.run([J.executable,R,S,T,O],check=A)for K in[b,c]:D=C.path.join(I,K)if not C.path.exists(D):B(f"Package directory not found: {D}",flush=A);continueB(f"Obfuscating {K}...",flush=A);E.run([O,'gen','--recursive','--output',C.path.join(I,Q),D],check=A);H=C.path.join(I,Q)if C.path.exists(H):for M in C.listdir(H):L=C.path.join(H,M);N=C.path.join(D,M)2 unmodified linesF.rmtree(H)else:B(f"Dist directory not found after obfuscation for {K}",flush=A);return Greturn Aexcept P as U:B(f"Error during obfuscation: {U}",flush=A);return Gdef Y():with H.listen(('',0))as A:return A.getsockname()[1]def r():J='Prompt Generator v0.2(More tags)';H='Prompt Generator v0.1(Better quality)';import gradio as C,random as M;from time import time,ctimedef F(choice,num,artist):L='art by';I=choice;E=artist;C=num;N=time();B(ctime(N))if I==H:G=open('pr1.txt').read().splitlines()elif I==J:G=open('pr2.txt').read().splitlines()if D(C)<1 or D(C)>20:C=10if D(E)<0 or D(E)>40:E=2O=len(G);A=[];K=0while len(sorted(Q(A),key=lambda d:A.index(d)))<D(C):F=M.choice(G)if F.startswith(L)and K<D(E):K+=1;A.append(F)elif not F.startswith(L):A.append(F)B(', '.join(Q(A))+'\n\n');return', '.join(Q(A))E=C.Blocks()with E:C.HTML('\n <div style="text-align: center; margin: 0 auto;">\n <div style="display: inline-flex;align-items: center;gap: 0.8rem;font-size: 1.75rem;">\n <h1 style="font-weight: 900; margin-bottom: 7px;margin-top:5px">\n Simple Prompt Generator v0.6 (Gradio Demo)\n </h1>\n </div>\n <p style="margin-bottom: 10px; font-size: 94%; line-height: 23px;">\n Simple prompt generation script for Midjourney, DALLe, Stable and Disco diffusion and etc neural networks. <br> <p>More examples in <a class=\'link-info\' href="https://github.com/WiNE-iNEFF/Simple_Prompt_Generator" target="_blank">Github</a> and <a class=\'link-info\' href="https://wine-ineff.github.io/Simple_Prompt_Generator/" target="_blank">Project site</a></p>\n </p>\n <center>\n <img style="display: inline-block, margin-right: 1%;" src=\'https://visitor-badge.laobi.icu/badge?page_id=WiNE-iNEFF.Simple_Prompt_Generator&left_color=red&right_color=green&left_text=Visitors\' alt=\'visitor badge\'>\n <img style="display: inline-block, margin-right: 1%;" src=\'https://visitor-badge.laobi.icu/badge?page_id=WiNE-iNEFF.HF_Simple_Prompt_Generator&left_color=red&right_color=green&left_text=Visitors\' alt=\'visitor badge\'>\n </center>\n </div>\n ')with C.Column():K=C.Radio([H,J],label='Model Variant',value=H);L=C.Number(value='10',label='Num of tag (MAX 20)',show_label=A);N=C.Number(value='2',label='Num of artist (Standart 2)',show_label=A);O=C.Textbox(lines=4,label='Generated Prompts')P=C.Button('Generate');P.click(fn=F,inputs=[K,L,N],outputs=O,concurrency_limit=4);C.HTML('\n <div class="footer">\n <div style=\'text-align: center;\'>Simple Prompt Generator by <a href=\'https://twitter.com/wine_ineff\' target=\'_blank\'>Artsem Holub (WiNE-iNEFF)</a><br>More information about this demo and script your can find in <a class=\'link-info\' href="https://github.com/WiNE-iNEFF/Simple_Prompt_Generator" target="_blank">Github</a> and <a class=\'link-info\' href="https://wine-ineff.github.io/Simple_Prompt_Generator/" target="_blank">Project site</a></div>\n </div>\n ')E.queue();B(f"Starting Gradio on port {I}",flush=A);E.launch(server_name='0.0.0.0',server_port=I,share=G,debug=A,show_error=A,prevent_thread_lock=A)def s():O='disconnect';K='connect';C='/pty';E=N.Server(async_mode='eventlet');P=N.WSGIApp(E);F=N.Client();J={}@E.on(K,namespace=C)def R(sid,environ):B(f"Client connected: {sid}")if not F.connected:F.connect('http://127.0.0.1:7862',namespaces=[C])J[sid]=A@E.on(O,namespace=C)def S(sid):B(f"Client disconnected: {sid}");J.pop(sid,U)if not J:F.disconnect()@E.on('*',namespace=C)def T(event,sid,*D):A=eventif A not in[K,O]:B(f"Forward to ek: {A}");F.emit(A,*D,namespace=C)@F.on('*',namespace=C)def W(event,*D):A=eventif A not in[K,O]:B(f"Forward from ek: {A}");E.emit(A,*D,namespace=C)def Q(environ,start_response):B=environ;H=B[d]if H.startswith(V):J=f"http://127.0.0.1:{L}"else:J=f"http://127.0.0.1:{I}"P=f"{J}{H}";F={}for(K,Q)in B.items():if K.startswith(e):N=K[5:].replace('_','-').title()if N.lower()not in[f,g,h]:F[N]=QC=B.get(i);O=Uif C:C=D(C);O=B[j].read(C)if B.get(M):F[k]=B[M]E=X.request(method=B[l],url=P,headers=F,data=O,stream=A,allow_redirects=G);start_response(f"{E.status_code} {E.reason}",list(E.headers.items()));return E.iter_content(chunk_size=4096)P.wsgi_app=Q;H.wsgi.server(H.listen(('',7860)),P)if __name__=='__main__':B('Setting up EK...',flush=A)if not p():B('Failed to setup EK!',flush=A);J.exit(1)I=Y();L=Y();B(f"Using ports - Gradio: {I}, EK: {L}",flush=A);Z=W.Thread(target=r);Z.daemon=A;Z.start();a=W.Thread(target=lambda:E.run([c,'--port',str(L),'--prefix',V,'--public']));a.daemon=A;a.start()def t(environ,start_response):B=environ;H=B[d]if H.startswith(V):J=f"http://127.0.0.1:{L}"else:J=f"http://127.0.0.1:{I}"P=f"{J}{H}";F={}for(K,Q)in B.items():if K.startswith(e):N=K[5:].replace('_','-').title()if N.lower()not in[f,g,h]:F[N]=QC=B.get(i);O=Uif C:C=D(C);O=B[j].read(C)if B.get(M):F[k]=B[M]E=X.request(method=B[l],url=P,headers=F,data=O,stream=A,allow_redirects=G);start_response(f"{E.status_code} {E.reason}",list(E.headers.items()));return E.iter_content(chunk_size=4096)B('Starting proxy server on port 7860...',flush=A);s()
app.py+70-70