Manjushri commited on
Commit
0521099
1 Parent(s): b4bce2e

Update app.py

Browse files

Adding story too?

Files changed (1) hide show
  1. app.py +20 -2
app.py CHANGED
@@ -22,6 +22,11 @@ disney = disney.to(device)
22
  disney.enable_xformers_memory_efficient_attention()
23
  torch.cuda.empty_cache()
24
 
 
 
 
 
 
25
  refiner = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", use_safetensors=True, torch_dtype=torch.float16, variant="fp16") if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0")
26
  refiner.enable_xformers_memory_efficient_attention()
27
  refiner = refiner.to(device)
@@ -50,7 +55,8 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, up
50
  image = anime(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images[0]
51
  torch.cuda.empty_cache()
52
  return image
53
- else:
 
54
  if upscale == "Yes":
55
  int_image = disney(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images
56
  image = refiner(Prompt, negative_prompt=negative_prompt, image=int_image, denoising_start=high_noise_frac).images[0]
@@ -59,9 +65,21 @@ def genie (Model, Prompt, negative_prompt, height, width, scale, steps, seed, up
59
  else:
60
  image = disney(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images[0]
61
  torch.cuda.empty_cache()
 
 
 
 
 
 
 
 
 
 
 
 
62
  return image
63
 
64
- gr.Interface(fn=genie, inputs=[gr.Radio(['Real', 'Anime', 'Disney'], value='Real', label='Choose Canvers Model'),
65
  gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
66
  gr.Textbox(label='What you Do Not want the AI to generate. 77 Token Limit'),
67
  gr.Slider(512, 1024, 768, step=128, label='Height'),
 
22
  disney.enable_xformers_memory_efficient_attention()
23
  torch.cuda.empty_cache()
24
 
25
+ story = DiffusionPipeline.from_pretrained("circulus/canvers-story-v3.8.1", torch_dtype=torch.float16, safety_checker=None) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("circulus/canvers-story-v3.8.1")
26
+ story = story.to(device)
27
+ story.enable_xformers_memory_efficient_attention()
28
+ torch.cuda.empty_cache()
29
+
30
  refiner = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", use_safetensors=True, torch_dtype=torch.float16, variant="fp16") if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0")
31
  refiner.enable_xformers_memory_efficient_attention()
32
  refiner = refiner.to(device)
 
55
  image = anime(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images[0]
56
  torch.cuda.empty_cache()
57
  return image
58
+
59
+ if Model == "Disney":
60
  if upscale == "Yes":
61
  int_image = disney(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images
62
  image = refiner(Prompt, negative_prompt=negative_prompt, image=int_image, denoising_start=high_noise_frac).images[0]
 
65
  else:
66
  image = disney(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images[0]
67
  torch.cuda.empty_cache()
68
+ return image
69
+
70
+ if Model == "Story":
71
+ if upscale == "Yes":
72
+ int_image = story(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images
73
+ image = refiner(Prompt, negative_prompt=negative_prompt, image=int_image, denoising_start=high_noise_frac).images[0]
74
+ torch.cuda.empty_cache()
75
+ return image
76
+ else:
77
+ image = story(Prompt, negative_prompt=negative_prompt, height=height, width=width, num_inference_steps=steps, guidance_scale=scale).images[0]
78
+ torch.cuda.empty_cache()
79
+
80
  return image
81
 
82
+ gr.Interface(fn=genie, inputs=[gr.Radio(['Real', 'Anime', 'Disney', 'Story'], value='Real', label='Choose Canvers Model'),
83
  gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
84
  gr.Textbox(label='What you Do Not want the AI to generate. 77 Token Limit'),
85
  gr.Slider(512, 1024, 768, step=128, label='Height'),