import os import cv2 import sys import time import uuid as bandaid import tarfile import gradio as gr from pathlib import Path from PIL import Image models = [ "johnslegers/epic-diffusion-v1.1", "andite/anything-v4.0", "runwayml/stable-diffusion-v1-5", "claudfuen/photorealistic-fuen-v1", "naclbit/trinart_stable_diffusion_v2", "nitrosocke/Arcane-Diffusion", "nitrosocke/archer-diffusion", "nitrosocke/elden-ring-diffusion", "nitrosocke/redshift-diffusion", "nitrosocke/spider-verse-diffusion", "nitrosocke/mo-di-diffusion", "nitrosocke/classic-anim-diffusion", "dreamlike-art/dreamlike-diffusion-1.0", "dreamlike-art/dreamlike-photoreal-2.0", "wavymulder/wavyfusion", "wavymulder/Analog-Diffusion", "prompthero/midjourney-v4-diffusion", "prompthero/openjourney", "dallinmackay/Van-Gogh-diffusion", "hakurei/waifu-diffusion", "DGSpitzer/Cyberpunk-Anime-Diffusion", "Fictiverse/Stable_Diffusion_BalloonArt_Model", "dallinmackay/Tron-Legacy-diffusion", "AstraliteHeart/pony-diffusion", "nousr/robo-diffusion", "CompVis/stable-diffusion-v1-4", ] current_model = models[0] text_gen1=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link") text_gen2=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link") text_gen3=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link") text_gen4=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link") text_gen5=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link") text_gen6=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link") text_gen7=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link") text_gen8=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link") models2=[ gr.Interface.load(f"models/{models[0]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[1]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[2]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[3]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[4]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[5]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[6]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[7]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[8]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[9]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[10]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[11]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[12]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[13]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[14]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[15]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[16]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[17]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[18]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[19]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[20]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[21]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[22]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[23]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[24]}",live=True,preprocess=True), gr.Interface.load(f"models/{models[25]}",live=True,preprocess=True), ] def text_it(inputs,text_gen1=text_gen1): go_t1=text_gen1(inputs) return(go_t1) def set_model(current_model): current_model = models[current_model] return gr.update(label=(f"{current_model}")),gr.update(label=(f"{current_model}")),gr.update(label=(f"{current_model}")),gr.update(label=(f"{current_model}")),gr.update(label=(f"{current_model}")),gr.update(label=(f"{current_model}")),gr.update(label=(f"{current_model}")),gr.update(label=(f"{current_model}")), def prime_the_thing(): #timestr = time.strftime("%Y%m%d-%H%M%S") timestr = bandaid.uuid4() if not os.path.exists(f'./frames{timestr}'): os.mkdir(f'./frames{timestr}') global frame_box global frame_file_box global frame_tar_box frame_box=[] frame_file_box=[] frame_tar_box=[] go=1 return timestr, go def go_fn(): num=1 return num def the_thing(inputs,input_rand, model_choice,num,top_num,timestr): if num != 0: if int(num) <= int(top_num): #proc1= inputs=f"{inputs}{input_rand}" proc1=models2[model_choice] output=proc1(inputs) #output_pro=Image.open(output) output_pro=cv2.imread(output) cv2.imwrite(f"./frames{timestr}/frame-{num}.png",output_pro) frame_file_box.append(Path(f"./frames{timestr}/frame-{num}.png")) frame_box.append(output) input_rand=f"{input_rand} " if int(num) < int(top_num): num=int(num)+1 elif int(num)==int(top_num): #frame_tar_box=[] with tarfile.open(f'frames{timestr}.tar.gz','w:gz') as tar: tar.add(f"./frames{timestr}",arcname=os.path.basename(f"./frames{timestr}")) frame_tar_box.append(Path(f'frames{timestr}.tar.gz')) else: pass else: num=0 pass else: print("ending") return frame_box,frame_file_box,frame_tar_box,num,input_rand css="""""" css=""" .max-h-\[55vh\]{ max-height:10vh;!important; } """ with gr.Blocks(css=css) as myface: with gr.Row(): with gr.Tab("Title"): gr.HTML("""