apapiu commited on
Commit
eeba8b2
1 Parent(s): 1b8b0ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -1,6 +1,6 @@
1
-
2
  import gradio as gr
3
  from PIL import Image
 
4
 
5
  from tld.denoiser import Denoiser
6
  from tld.diffusion import DiffusionGenerator
@@ -19,10 +19,13 @@ device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
19
  to_pil = transforms.ToPILImage()
20
 
21
 
22
- ###config:
23
- vae_scale_factor = 8
24
- img_size = 32
25
- model_dtype = torch.float32
 
 
 
26
 
27
  @torch.no_grad()
28
  def encode_text(label, model):
@@ -55,6 +58,14 @@ def generate_image_from_text(prompt, class_guidance=6, seed=11, num_imgs=1, img_
55
  print("Images Generated and Saved. They will shortly output below.")
56
  return out
57
 
 
 
 
 
 
 
 
 
58
 
59
 
60
  denoiser = Denoiser(image_size=32, noise_embed_dims=256, patch_size=2,
@@ -85,4 +96,4 @@ iface = gr.Interface(
85
  )
86
 
87
  # Launch the app
88
- iface.launch()
 
 
1
  import gradio as gr
2
  from PIL import Image
3
+ import requests
4
 
5
  from tld.denoiser import Denoiser
6
  from tld.diffusion import DiffusionGenerator
 
19
  to_pil = transforms.ToPILImage()
20
 
21
 
22
+ def download_file(url, filename):
23
+
24
+ with requests.get(url, stream=True) as r:
25
+ r.raise_for_status()
26
+ with open(filename, 'wb') as f:
27
+ for chunk in r.iter_content(chunk_size=8192):
28
+ f.write(chunk)
29
 
30
  @torch.no_grad()
31
  def encode_text(label, model):
 
58
  print("Images Generated and Saved. They will shortly output below.")
59
  return out
60
 
61
+ ###config:
62
+ vae_scale_factor = 8
63
+ img_size = 32
64
+ model_dtype = torch.float32
65
+
66
+ file_url = "https://huggingface.co/apapiu/small_ldt/resolve/main/state_dict_378000.pth"
67
+ local_filename = "state_dict_378000.pth"
68
+ download_file(file_url, local_filename)
69
 
70
 
71
  denoiser = Denoiser(image_size=32, noise_embed_dims=256, patch_size=2,
 
96
  )
97
 
98
  # Launch the app
99
+ iface.launch()