Kingoteam commited on
Commit
1ee4fe5
·
verified ·
1 Parent(s): 94c1370

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -6,21 +6,25 @@ from realesrgan import RealESRGANer
6
  from basicsr.archs.rrdbnet_arch import RRDBNet
7
  from huggingface_hub import hf_hub_download
8
 
9
- # دانلود مدل x2
10
  model_path = hf_hub_download(
11
- repo_id="lllyasviel/Annotators",
12
  filename="RealESRGAN_x4plus.pth"
13
  )
14
 
15
- # تعریف معماری RRDBNet (x2)
16
  model = RRDBNet(
17
- num_in_ch=3, num_out_ch=3, num_feat=64,
18
- num_block=23, num_grow_ch=32, scale=2
 
 
 
 
19
  )
20
 
21
  # لود مدل
22
  upsampler = RealESRGANer(
23
- scale=2,
24
  model_path=model_path,
25
  model=model,
26
  tile=0,
@@ -31,15 +35,15 @@ upsampler = RealESRGANer(
31
 
32
  def upscale_image(img: Image.Image):
33
  img = img.convert("RGB")
34
- output, _ = upsampler.enhance(np.array(img), outscale=2)
35
  return Image.fromarray(output)
36
 
37
  demo = gr.Interface(
38
  fn=upscale_image,
39
  inputs=gr.Image(type="pil"),
40
  outputs="image",
41
- title="Real-ESRGAN x2plus",
42
- description="افزایش کیفیت تصویر با مدل سبک‌تر (x2 upscale)"
43
  )
44
 
45
  if __name__ == "__main__":
 
6
  from basicsr.archs.rrdbnet_arch import RRDBNet
7
  from huggingface_hub import hf_hub_download
8
 
9
+ # دانلود مدل x4
10
  model_path = hf_hub_download(
11
+ repo_id="dtarnow/UPscaler",
12
  filename="RealESRGAN_x4plus.pth"
13
  )
14
 
15
+ # تعریف معماری RRDBNet (x4)
16
  model = RRDBNet(
17
+ num_in_ch=3,
18
+ num_out_ch=3,
19
+ num_feat=64,
20
+ num_block=23,
21
+ num_grow_ch=32,
22
+ scale=4
23
  )
24
 
25
  # لود مدل
26
  upsampler = RealESRGANer(
27
+ scale=4,
28
  model_path=model_path,
29
  model=model,
30
  tile=0,
 
35
 
36
  def upscale_image(img: Image.Image):
37
  img = img.convert("RGB")
38
+ output, _ = upsampler.enhance(np.array(img), outscale=4)
39
  return Image.fromarray(output)
40
 
41
  demo = gr.Interface(
42
  fn=upscale_image,
43
  inputs=gr.Image(type="pil"),
44
  outputs="image",
45
+ title="Real-ESRGAN x4plus",
46
+ description="افزایش کیفیت تصویر (Upscale ×4)"
47
  )
48
 
49
  if __name__ == "__main__":