52Hz commited on
Commit
2fccf3a
·
1 Parent(s): dc67593

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -6,15 +6,18 @@ from PIL import Image
6
  os.system('wget https://github.com/FanChiMao/HWMNet/releases/download/v0.0/LOL_enhancement_HWMNet.pth -P experiments/pretrained_models')
7
  os.system('wget https://github.com/FanChiMao/HWMNet/releases/download/v0.0/MIT5K_enhancement_HWMNet.pth -P experiments/pretrained_models')
8
 
9
- def inference(img):
10
  os.system('mkdir test')
11
  #basewidth = 256
12
  #wpercent = (basewidth / float(img.size[0]))
13
  #hsize = int((float(img.size[1]) * float(wpercent)))
14
  #img = img.resize((basewidth, hsize), Image.ANTIALIAS)
15
  img.save("test/1.png", "PNG")
16
- os.system(
17
- 'python main_test_HWMNet.py --input_dir test --weights experiments/pretrained_models/LOL_enhancement_HWMNet.pth')
 
 
 
18
  return 'result/1.png'
19
 
20
 
@@ -26,6 +29,7 @@ examples = [['low-light.png']]
26
  gr.Interface(
27
  inference,
28
  [gr.inputs.Image(type="pil", label="Input")],
 
29
  gr.outputs.Image(type="file", label="Output"),
30
  title=title,
31
  description=description,
 
6
  os.system('wget https://github.com/FanChiMao/HWMNet/releases/download/v0.0/LOL_enhancement_HWMNet.pth -P experiments/pretrained_models')
7
  os.system('wget https://github.com/FanChiMao/HWMNet/releases/download/v0.0/MIT5K_enhancement_HWMNet.pth -P experiments/pretrained_models')
8
 
9
+ def inference(img, model):
10
  os.system('mkdir test')
11
  #basewidth = 256
12
  #wpercent = (basewidth / float(img.size[0]))
13
  #hsize = int((float(img.size[1]) * float(wpercent)))
14
  #img = img.resize((basewidth, hsize), Image.ANTIALIAS)
15
  img.save("test/1.png", "PNG")
16
+ if model == 'LOL':
17
+ os.system('python main_test_HWMNet.py --input_dir test --weights experiments/pretrained_models/LOL_enhancement_HWMNet.pth')
18
+ elif model == 'MIT-5K':
19
+ os.system('python main_test_HWMNet.py --input_dir test --weights experiments/pretrained_models/MIT5K_enhancement_HWMNet.pth')
20
+
21
  return 'result/1.png'
22
 
23
 
 
29
  gr.Interface(
30
  inference,
31
  [gr.inputs.Image(type="pil", label="Input")],
32
+ gr.inputs.Dropdown(choices=['LOL', 'MIT-5K'], type="value", default='LOL', label="model")],
33
  gr.outputs.Image(type="file", label="Output"),
34
  title=title,
35
  description=description,