Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -67,11 +67,12 @@ def load_model(file_name: str, path:str,device: torch.device) -> nn.Module:
|
|
67 |
model(z, label, force_fp32=True)
|
68 |
return model
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
75 |
|
76 |
def main():
|
77 |
#torch.cuda.init()
|
@@ -91,30 +92,22 @@ def main():
|
|
91 |
log_visual_freq=1000,
|
92 |
input='text',
|
93 |
))
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
#inputs='text',
|
102 |
-
#gr.outputs.Image(type='numpy', label='Output'),
|
103 |
-
#title=TITLE,
|
104 |
-
#description=DESCRIPTION,
|
105 |
-
#article=ARTICLE,
|
106 |
#theme=args.theme,
|
107 |
#allow_flagging=args.allow_flagging,
|
108 |
#live=args.live,
|
109 |
-
|
110 |
|
111 |
-
|
112 |
#enable_queue=args.enable_queue,
|
113 |
#server_port=args.port,
|
114 |
-
#share=args.share,
|
115 |
-
#)
|
116 |
-
demo = gr.Interface(fn=image_create, inputs="text", outputs="image")
|
117 |
-
demo.launch()
|
118 |
if __name__ == '__main__':
|
119 |
main()
|
120 |
|
|
|
67 |
model(z, label, force_fp32=True)
|
68 |
return model
|
69 |
|
70 |
+
def image_create(input_img):
|
71 |
+
device = th.device()
|
72 |
+
generator = create_generator("stylegan2-ffhq-config-f.pt","feng2022/Time-TravelRephotography_stylegan2-ffhq-config-f",args, device)
|
73 |
+
latent = torch.randn((1, 512), device=device)
|
74 |
+
img_out, _, _ = generator([latent])
|
75 |
+
imgs_arr = make_image(img_out)
|
76 |
|
77 |
def main():
|
78 |
#torch.cuda.init()
|
|
|
92 |
log_visual_freq=1000,
|
93 |
input='text',
|
94 |
))
|
95 |
+
iface = gr.Interface(
|
96 |
+
fn=image_create,
|
97 |
+
inputs='text',
|
98 |
+
gr.outputs.Image(type='numpy', label='Output'),
|
99 |
+
title=TITLE,
|
100 |
+
description=DESCRIPTION,
|
101 |
+
article=ARTICLE,
|
|
|
|
|
|
|
|
|
|
|
102 |
#theme=args.theme,
|
103 |
#allow_flagging=args.allow_flagging,
|
104 |
#live=args.live,
|
105 |
+
)
|
106 |
|
107 |
+
iface.launch()
|
108 |
#enable_queue=args.enable_queue,
|
109 |
#server_port=args.port,
|
110 |
+
#share=args.share,)
|
|
|
|
|
|
|
111 |
if __name__ == '__main__':
|
112 |
main()
|
113 |
|