owsgfwnlgjuz kadirnar commited on
Commit
c4e98b7
0 Parent(s):

Duplicate from kadirnar/bsrgan

Browse files

Co-authored-by: Kadir Nar <kadirnar@users.noreply.huggingface.co>

Files changed (4) hide show
  1. .gitattributes +34 -0
  2. README.md +16 -0
  3. app.py +59 -0
  4. requirements.txt +2 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Bsrgan
3
+ emoji: 🔥
4
+ colorFrom: purple
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ sdk_version: 3.14.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: apache-2.0
11
+ tags:
12
+ - making-demos
13
+ duplicated_from: kadirnar/bsrgan
14
+ ---
15
+
16
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from bsrgan import BSRGAN
4
+
5
+ # Images
6
+ torch.hub.download_url_to_file('https://raw.githubusercontent.com/kadirnar/bsrgan-pip/main/data/images/butterfly.png', 'butterfly.jpg')
7
+
8
+ def bsrgan_inference(
9
+ image: gr.inputs.Image = None,
10
+ model_path: gr.inputs.Dropdown = 'kadirnar/bsrgan',
11
+ ):
12
+ """
13
+ BSRGAN inference function
14
+ Args:
15
+ image: Input image
16
+ model_path: Path to the model
17
+ Returns:
18
+ Rendered image
19
+ """
20
+ device = 'cuda:0' if torch.cuda.is_available() else 'cpu'
21
+ model = BSRGAN(model_path, device=device, hf_model=True)
22
+ pred = model.predict(img_path=image)
23
+ return pred
24
+
25
+
26
+ inputs = [
27
+ gr.inputs.Image(type="filepath", label="Input Image"),
28
+ gr.inputs.Dropdown(
29
+ label="Model",
30
+ choices=[
31
+ "kadirnar/bsrgan",
32
+ "kadirnar/BSRGANx2",
33
+ "kadirnar/RRDB_PSNR_x4",
34
+ "kadirnar/RRDB_ESRGAN_x4",
35
+ "kadirnar/DF2K",
36
+ "kadirnar/DPED",
37
+ "kadirnar/DF2K_JPEG",
38
+ ],
39
+ default="kadirnar/bsrgan",
40
+ ),
41
+ ]
42
+
43
+ outputs = gr.outputs.Image(type="filepath", label="Output Image")
44
+ title = "BSRGAN: Designing a Practical Degradation Model for Deep Blind Image Super-Resolution."
45
+ description = "BSRGAN for Deep Blind Image Super-Resolution model aims to design a practical degradation model for deep blind image super-resolution by considering the deterioration of image quality over time. It uses deep learning methods to predict the deterioration of image quality and to assist in the re-creation of images at higher resolution using these predictions."
46
+ examples = [["butterfly.jpg", "kadirnar/bsrgan"]]
47
+
48
+ demo_app = gr.Interface(
49
+ fn=bsrgan_inference,
50
+ inputs=inputs,
51
+ outputs=outputs,
52
+ title=title,
53
+ description=description,
54
+ examples=examples,
55
+ cache_examples=True,
56
+ live=True,
57
+ theme='huggingface',
58
+ )
59
+ demo_app.launch(debug=True, enable_queue=True)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ torch
2
+ bsrgan==0.1.5