Spaces:
Sleeping
Sleeping
WebashalarForML
commited on
Commit
•
bd55508
1
Parent(s):
230d404
Update utility/utils.py
Browse files- utility/utils.py +4 -3
utility/utils.py
CHANGED
@@ -45,15 +45,16 @@ HFT = os.getenv('HF_TOKEN')
|
|
45 |
# Initialize the InferenceClient
|
46 |
client = InferenceClient(model="mistralai/Mistral-7B-Instruct-v0.3", token=HFT)
|
47 |
|
48 |
-
# Load image using OpenCV
|
49 |
def load_image(image_path):
|
50 |
ext = os.path.splitext(image_path)[1].lower()
|
51 |
if ext in ['.png', '.jpg', '.jpeg', '.webp', '.tiff']:
|
52 |
image = cv2.imread(image_path)
|
|
|
|
|
53 |
return image
|
54 |
else:
|
55 |
-
raise ValueError(f"
|
56 |
-
|
57 |
# Function for upscaling image using OpenCV's INTER_CUBIC
|
58 |
def upscale_image(image, scale=2):
|
59 |
height, width = image.shape[:2]
|
|
|
45 |
# Initialize the InferenceClient
|
46 |
client = InferenceClient(model="mistralai/Mistral-7B-Instruct-v0.3", token=HFT)
|
47 |
|
|
|
48 |
def load_image(image_path):
|
49 |
ext = os.path.splitext(image_path)[1].lower()
|
50 |
if ext in ['.png', '.jpg', '.jpeg', '.webp', '.tiff']:
|
51 |
image = cv2.imread(image_path)
|
52 |
+
if image is None:
|
53 |
+
raise ValueError(f"Failed to load image from {image_path}. The file may be corrupted or unreadable.")
|
54 |
return image
|
55 |
else:
|
56 |
+
raise ValueError(f"Unsupported image format: {ext}")
|
57 |
+
|
58 |
# Function for upscaling image using OpenCV's INTER_CUBIC
|
59 |
def upscale_image(image, scale=2):
|
60 |
height, width = image.shape[:2]
|