English
Inference Endpoints
garg-aayush commited on
Commit
a7f6fc5
1 Parent(s): d23c8e6

update real-esrgan to upscale images using tile size of 1000 px

Browse files
Files changed (2) hide show
  1. handler.py +3 -3
  2. unit_tests.py +0 -9
handler.py CHANGED
@@ -21,6 +21,7 @@ class EndpointHandler:
21
  self.model = RealESRGANer(
22
  scale=4,
23
  model_path=f"/repository/weights/Real-ESRGAN-x4plus.pth",
 
24
  # dni_weight=dni_weight,
25
  model= RRDBNet(num_in_ch=3,
26
  num_out_ch=3,
@@ -29,8 +30,8 @@ class EndpointHandler:
29
  num_grow_ch=32,
30
  scale=4
31
  ),
32
- tile=0,
33
- tile_pad=10,
34
  # pre_pad=args.pre_pad,
35
  half=True,
36
  # gpu_id=args.gpu_id
@@ -52,7 +53,6 @@ class EndpointHandler:
52
 
53
  # check image size and mode and return dict
54
  assert in_mode in ["RGB", "RGBA", "L"], f"Unsupported image mode: {in_mode}"
55
- assert in_size[0] * in_size[1] < 1400*1400, f"Image is too large: {in_size}: {in_size[0] * in_size[1]} is greater than {1400*1400}"
56
  assert outscale > 1 and outscale <=10, f"Outscale must be between 1 and 10: {outscale}"
57
 
58
  # debug
 
21
  self.model = RealESRGANer(
22
  scale=4,
23
  model_path=f"/repository/weights/Real-ESRGAN-x4plus.pth",
24
+ # model_path=f"/workspace/real-esrgan/weights/Real-ESRGAN-x4plus.pth",
25
  # dni_weight=dni_weight,
26
  model= RRDBNet(num_in_ch=3,
27
  num_out_ch=3,
 
30
  num_grow_ch=32,
31
  scale=4
32
  ),
33
+ tile=1000,
34
+ tile_pad=20,
35
  # pre_pad=args.pre_pad,
36
  half=True,
37
  # gpu_id=args.gpu_id
 
53
 
54
  # check image size and mode and return dict
55
  assert in_mode in ["RGB", "RGBA", "L"], f"Unsupported image mode: {in_mode}"
 
56
  assert outscale > 1 and outscale <=10, f"Outscale must be between 1 and 10: {outscale}"
57
 
58
  # debug
unit_tests.py CHANGED
@@ -74,15 +74,6 @@ class TestEndpointHandler(unittest.TestCase):
74
  self.assertIn("out_image", result)
75
  self.assertIsNone(result["error"])
76
 
77
- def test_image_too_large(self):
78
- test_image = self.create_test_image(size=(1500, 1500))
79
- input_data = {"inputs": {"image": test_image}}
80
-
81
- result = self.handler(input_data)
82
-
83
- self.assertIsNone(result["out_image"])
84
- self.assertIn("Image is too large", result["error"])
85
-
86
  def test_missing_image_key(self):
87
  input_data = {"inputs": {}}
88
 
 
74
  self.assertIn("out_image", result)
75
  self.assertIsNone(result["error"])
76
 
 
 
 
 
 
 
 
 
 
77
  def test_missing_image_key(self):
78
  input_data = {"inputs": {}}
79