Spaces:
Runtime error
Runtime error
Commit ·
b815b4e
1
Parent(s): deb41ea
Update app.py
Browse files11 unmodified lines1213141516173 unmodified lines2122232425262710 unmodified lines383940414243444546204 unmodified lines2512522532542552562579 unmodified lines26726826927027127227311 unmodified linesfrom tqdm.auto import tqdmfrom transformers import CLIPTextModel, CLIPTokenizer, loggingimport osimport cv2import torchvision.transforms as T3 unmodified linestorch_device = "cuda" if torch.cuda.is_available() else "cpu"# Load the autoencodervae = AutoencoderKL.from_pretrained("CompVis/stable-diffusion-v1-4", subfolder='vae')# Load tokenizer and text encoder to tokenize and encode the texttokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-large-patch14")10 unmodified linestext_encoder = text_encoder.to(torch_device)unet = unet.to(torch_device)style_files = ['Thumps_up.bin', 'birb_style.bin','snoopy.bin', 'pop_art.bin','boot-mjstyle.bin']images_without_loss = []images_with_loss = []204 unmodified lines# plt.show()def image_generator(prompt = "snoopy", loss_function=None):images_without_loss = []images_with_loss = []if loss_function == "Yes":9 unmodified linesimages_with_loss.append(generated_img)generated_sd_images = []titles = ["Bird_style", "Boot-mjstyle", "Snoopy Style", "Pop Art Style", "Thumpsup Style"]for i in range(len(titles)):generated_sd_images.append((images_without_loss[i], titles[i]))11 unmodified lines121314151617183 unmodified lines2223242526272810 unmodified lines394041424344454647204 unmodified lines2522532542552562572589 unmodified lines26826927027127227327411 unmodified linesfrom tqdm.auto import tqdmfrom transformers import CLIPTextModel, CLIPTokenizer, loggingimport osMY_TOKEN=os.environ.get('Stable_Diffusion')import cv2import torchvision.transforms as T3 unmodified linestorch_device = "cuda" if torch.cuda.is_available() else "cpu"# Load the autoencodervae = AutoencoderKL.from_pretrained("CompVis/stable-diffusion-v1-4", subfolder="vae",use_auth_token=MY_TOKEN)# Load tokenizer and text encoder to tokenize and encode the texttokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-large-patch14")10 unmodified linestext_encoder = text_encoder.to(torch_device)unet = unet.to(torch_device)style_files = ['bird_style.bin', 'ronaldo.bin','pop_art.bin', 'threestooges.bin','bflan.bin']images_without_loss = []images_with_loss = []204 unmodified lines# plt.show()def image_generator(prompt = "sky", loss_function=None):images_without_loss = []images_with_loss = []if loss_function == "Yes":9 unmodified linesimages_with_loss.append(generated_img)generated_sd_images = []titles = ["<birb-style>", "'<ronaldo>", "<pop-art>", "<threestooges>", "<Marbled-painting>"]for i in range(len(titles)):generated_sd_images.append((images_without_loss[i], titles[i]))
app.py+7-6