areebsatin commited on
Commit
fc53afe
·
1 Parent(s): 6a145c0

Completely remove PIL Image schemas from Gradio endpoints

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. core.py +5 -8
app.py CHANGED
@@ -72,7 +72,7 @@ with gr.Blocks(css=CSS, title="4K Upscaler Pro") as demo:
72
  with gr.TabItem("🖼 Image Upscaler"):
73
  with gr.Row():
74
  with gr.Column():
75
- img_input = gr.Image(type="pil", label="Upload Image")
76
  img_method = gr.Radio(
77
  ["Real-ESRGAN (AI)", "Lanczos (Fast)"],
78
  value="Lanczos (Fast)",
 
72
  with gr.TabItem("🖼 Image Upscaler"):
73
  with gr.Row():
74
  with gr.Column():
75
+ img_input = gr.Image(type="filepath", label="Upload Image")
76
  img_method = gr.Radio(
77
  ["Real-ESRGAN (AI)", "Lanczos (Fast)"],
78
  value="Lanczos (Fast)",
core.py CHANGED
@@ -61,15 +61,14 @@ def opencv_upscale(img_np: np.ndarray, target_w: int, target_h: int) -> np.ndarr
61
  return cv2.resize(img_np, (target_w, target_h), interpolation=cv2.INTER_LANCZOS4)
62
 
63
 
64
- from typing import Any
65
-
66
- def upscale_image(
67
- image: Any, method: str, target_str: str
68
- ) -> tuple[Any, str, Any]:
69
 
70
  if image is None:
71
  return None, "❌ No image provided.", None
72
 
 
 
 
73
  try:
74
  target = TargetResolution(target_str)
75
  except ValueError:
@@ -106,9 +105,7 @@ def upscale_image(
106
  return result_img, info, tmp_path
107
 
108
 
109
- def upscale_video(
110
- video_path: str | None, method: str, target_str: str, progress_callback=None
111
- ) -> tuple[str | None, str]:
112
 
113
  if not video_path:
114
  return None, "❌ No video provided."
 
61
  return cv2.resize(img_np, (target_w, target_h), interpolation=cv2.INTER_LANCZOS4)
62
 
63
 
64
+ def upscale_image(image, method, target_str):
 
 
 
 
65
 
66
  if image is None:
67
  return None, "❌ No image provided.", None
68
 
69
+ if isinstance(image, str):
70
+ image = Image.open(image)
71
+
72
  try:
73
  target = TargetResolution(target_str)
74
  except ValueError:
 
105
  return result_img, info, tmp_path
106
 
107
 
108
+ def upscale_video(video_path, method, target_str, progress_callback=None):
 
 
109
 
110
  if not video_path:
111
  return None, "❌ No video provided."