doevent commited on
Commit
269eef7
1 Parent(s): 34cedfe

delete gdown

Browse files
Files changed (1) hide show
  1. app.py +11 -14
app.py CHANGED
@@ -1,20 +1,16 @@
1
  import torch
2
  from PIL import Image
3
  import numpy as np
4
- from realesrgan import RealESRGAN
5
- import os
6
  import gradio as gr
7
- os.system("gdown https://drive.google.com/uc?id=1pG2S3sYvSaO0V0B8QPOl1RapPHpUGOaV -O RealESRGAN_x2.pth")
8
- os.system("gdown https://drive.google.com/uc?id=1SGHdZAln4en65_NQeQY9UjchtkEF9f5F -O RealESRGAN_x4.pth")
9
- os.system("gdown https://drive.google.com/uc?id=1mT9ewx86PSrc43b-ax47l1E2UzR7Ln4j -O RealESRGAN_x8.pth")
10
 
11
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
12
  model2 = RealESRGAN(device, scale=2)
13
- model2.load_weights('RealESRGAN_x2.pth')
14
  model4 = RealESRGAN(device, scale=4)
15
- model4.load_weights('RealESRGAN_x4.pth')
16
  model8 = RealESRGAN(device, scale=8)
17
- model8.load_weights('RealESRGAN_x8.pth')
18
 
19
 
20
  def inference(image: Image, size: str) -> Image:
@@ -31,13 +27,14 @@ title = "Face Real ESRGAN: 2x 4x 8x"
31
  description = "This is an unofficial demo for Real-ESRGAN. Scales the resolution of a photo. This model shows better results on faces compared to the original version.<br>Telegram BOT: https://t.me/restoration_photo_bot"
32
  article = "<div style='text-align: center;'>Twitter <a href='https://twitter.com/DoEvent' target='_blank'>Max Skobeev</a> | <a href='https://huggingface.co/sberbank-ai/Real-ESRGAN' target='_blank'>Model card</a> <center><img src='https://visitor-badge.glitch.me/badge?page_id=max_skobeev_face_esrgan' alt='visitor badge'></center></div>"
33
 
 
34
  gr.Interface(inference,
35
- [gr.inputs.Image(type="pil"),
36
- gr.inputs.Radio(['2x', '4x', '8x'],
37
- type="value",
38
- default='2x',
39
  label='Resolution model')],
40
- gr.outputs.Image(type="pil", label="Output"),
41
  title=title,
42
  description=description,
43
  article=article,
@@ -45,5 +42,5 @@ gr.Interface(inference,
45
  allow_flagging='never',
46
  theme="default",
47
  cache_examples=False,
48
- ).queue().launch()
49
 
 
1
  import torch
2
  from PIL import Image
3
  import numpy as np
4
+ from RealESRGAN import RealESRGAN
 
5
  import gradio as gr
 
 
 
6
 
7
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
8
  model2 = RealESRGAN(device, scale=2)
9
+ model2.load_weights('weights/RealESRGAN_x2.pth', download=True)
10
  model4 = RealESRGAN(device, scale=4)
11
+ model4.load_weights('weights/RealESRGAN_x4.pth', download=True)
12
  model8 = RealESRGAN(device, scale=8)
13
+ model8.load_weights('weights/RealESRGAN_x8.pth', download=True)
14
 
15
 
16
  def inference(image: Image, size: str) -> Image:
 
27
  description = "This is an unofficial demo for Real-ESRGAN. Scales the resolution of a photo. This model shows better results on faces compared to the original version.<br>Telegram BOT: https://t.me/restoration_photo_bot"
28
  article = "<div style='text-align: center;'>Twitter <a href='https://twitter.com/DoEvent' target='_blank'>Max Skobeev</a> | <a href='https://huggingface.co/sberbank-ai/Real-ESRGAN' target='_blank'>Model card</a> <center><img src='https://visitor-badge.glitch.me/badge?page_id=max_skobeev_face_esrgan' alt='visitor badge'></center></div>"
29
 
30
+
31
  gr.Interface(inference,
32
+ [gr.Image(type="pil"),
33
+ gr.Radio(['2x', '4x', '8x'],
34
+ type="value",
35
+ value='2x',
36
  label='Resolution model')],
37
+ gr.Image(type="pil", label="Output"),
38
  title=title,
39
  description=description,
40
  article=article,
 
42
  allow_flagging='never',
43
  theme="default",
44
  cache_examples=False,
45
+ ).queue().launch(show_error=True)
46