akhaliq HF staff commited on
Commit
2b46fce
1 Parent(s): 77cd033

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -1,6 +1,8 @@
1
  import os
2
  import gradio as gr
3
  from PIL import Image
 
 
4
 
5
  os.system("git clone https://github.com/AK391/stylegan2-ada-pytorch")
6
 
@@ -10,10 +12,11 @@ os.chdir("stylegan2-ada-pytorch")
10
  os.mkdir("outputs")
11
  os.mkdir("outputs/images")
12
 
13
- os.system("gdown --id '11qCXjJg0-VQaKrdufnC5-XTTQJdTHbOC'")
 
14
 
15
  def inference(truncation,seeds):
16
- os.system("python generate.py --outdir=./outputs/images/ --trunc="+str(truncation)+" --seeds="+str(int(seeds))+" --network=mammoGANesis.pkl")
17
  seeds = int(seeds)
18
  image = Image.open(f"./outputs/images/seed{seeds:04d}.png")
19
  return image
 
1
  import os
2
  import gradio as gr
3
  from PIL import Image
4
+ from huggingface_hub import hf_hub_url, cached_download
5
+
6
 
7
  os.system("git clone https://github.com/AK391/stylegan2-ada-pytorch")
8
 
 
12
  os.mkdir("outputs")
13
  os.mkdir("outputs/images")
14
 
15
+ config_file_url = hf_hub_url("AUBMC-AIM/MammoGANesis", filename="mammoGANesis.pkl")
16
+ cached_file = cached_download(config_file_url)
17
 
18
  def inference(truncation,seeds):
19
+ os.system("python generate.py --outdir=./outputs/images/ --trunc="+str(truncation)+" --seeds="+str(int(seeds))+" --network="+cached_file)
20
  seeds = int(seeds)
21
  image = Image.open(f"./outputs/images/seed{seeds:04d}.png")
22
  return image