danielsapit commited on
Commit
535092b
1 Parent(s): a91c837

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -19
app.py CHANGED
@@ -32,17 +32,7 @@ def inference(input_img, is_gray, input_quality, enable_zoom, zoom, x_shift, y_s
32
 
33
  input_quality = 100 - input_quality
34
 
35
- #model_pool = '/FBCNN/model_zoo' # fixed
36
- #model_path = os.path.join(model_pool, model_name)
37
- model_path = model_name
38
- """
39
- if os.path.exists(model_path):
40
- print(f'loading model from {model_path}')
41
- else:
42
- os.makedirs(os.path.dirname(model_path), exist_ok=True)
43
- url = 'https://github.com/jiaxi-jiang/FBCNN/releases/download/v1.0/{}'.format(os.path.basename(model_path))
44
- r = requests.get(url, allow_redirects=True)
45
- open(model_path, 'wb').write(r.content)"""
46
 
47
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
48
 
@@ -124,16 +114,16 @@ interface = gr.Interface(
124
  fn = inference,
125
  inputs = [gr.inputs.Image(),
126
  gr.inputs.Checkbox(label="Grayscale (Check this if your image is grayscale)"),
127
- gr.inputs.Slider(minimum=1, maximum=100, step=1, label="Intensity (Higher = more JPEG artifact removal)"),
128
- gr.inputs.Checkbox(default=False, label="Edit Zoom preview \n(This is optional. "
129
- "Check this after the image result is loaded to edit zoom parameters\n"
130
  "without processing the input image.)"),
131
- gr.inputs.Slider(minimum=10, maximum=100, step=1, default=50, label="Zoom Image \n"
132
- "(Use this to see the image quality up close. \n"
133
  "100 = original size)"),
134
- gr.inputs.Slider(minimum=0, maximum=100, step=1, label="Zoom preview horizontal shift \n"
135
  "(Increase to shift to the right)"),
136
- gr.inputs.Slider(minimum=0, maximum=100, step=1, label="Zoom preview vertical shift \n"
137
  "(Increase to shift downwards)"),
138
  gr.inputs.State(default=[None,None])
139
  ],
@@ -147,5 +137,10 @@ interface = gr.Interface(
147
  ["cemetry.jpg",False,70,False,20,44,77],
148
  ["michelangelo_david.jpg",True,30,False,12,53,27],
149
  ["elon_musk.jpg",False,45,False,15,33,30]],
 
 
 
 
 
150
  allow_flagging=False
151
- ).launch(enable_queue=True)
 
32
 
33
  input_quality = 100 - input_quality
34
 
35
+ model_path = model_name
 
 
 
 
 
 
 
 
 
 
36
 
37
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
38
 
 
114
  fn = inference,
115
  inputs = [gr.inputs.Image(),
116
  gr.inputs.Checkbox(label="Grayscale (Check this if your image is grayscale)"),
117
+ gr.inputs.Slider(minimum=1, maximum=100, step=1, label="Intensity (Higher = stronger JPEG artifact removal)"),
118
+ gr.inputs.Checkbox(default=False, label="Edit Zoom preview (This is optional. "
119
+ "Check this after the image result is loaded to edit zoom parameters"
120
  "without processing the input image.)"),
121
+ gr.inputs.Slider(minimum=10, maximum=100, step=1, default=50, label="Zoom Image "
122
+ "(Use this to see the image quality up close. "
123
  "100 = original size)"),
124
+ gr.inputs.Slider(minimum=0, maximum=100, step=1, label="Zoom preview horizontal shift "
125
  "(Increase to shift to the right)"),
126
+ gr.inputs.Slider(minimum=0, maximum=100, step=1, label="Zoom preview vertical shift "
127
  "(Increase to shift downwards)"),
128
  gr.inputs.State(default=[None,None])
129
  ],
 
137
  ["cemetry.jpg",False,70,False,20,44,77],
138
  ["michelangelo_david.jpg",True,30,False,12,53,27],
139
  ["elon_musk.jpg",False,45,False,15,33,30]],
140
+ title = "JPEG Artifacts Removal [FBCNN]",
141
+ description = "Gradio Demo for JPEG Artifacts Removal. To use it, simply upload your image, "
142
+ "or click one of the examples to load them. Checkout the original GitHub at the link below. "
143
+ "JPEG artifacts are noticeable distortion of images caused by JPEG lossy compression. "
144
+ "This is not a super resolution AI but a JPEG compression artifact remover.",
145
  allow_flagging=False
146
+ ).launch(enable_queue=True,cache_examples=True)