Spaces:
Runtime error
Runtime error
Update utility/utils.py
Browse files- utility/utils.py +14 -4
utility/utils.py
CHANGED
@@ -47,10 +47,20 @@ client = InferenceClient(model="mistralai/Mistral-7B-Instruct-v0.3", token=HFT)
|
|
47 |
|
48 |
# Load image using OpenCV
|
49 |
def load_image(image_path):
|
50 |
-
|
51 |
-
if
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
# Function for upscaling image using OpenCV's INTER_CUBIC
|
56 |
def upscale_image(image, scale=2):
|
|
|
47 |
|
48 |
# Load image using OpenCV
|
49 |
def load_image(image_path):
|
50 |
+
ext = os.path.splitext(file_path)[1].lower()
|
51 |
+
if ext in ['.png', '.jpg', '.jpeg']:
|
52 |
+
image = cv2.imread(image_path)
|
53 |
+
return image
|
54 |
+
else:
|
55 |
+
raise ValueError(f"Could not load image from {image_path}. It may be corrupted or the path is incorrect. or in a not supported format")
|
56 |
+
|
57 |
+
def extract_hyperlinks(file_path):
|
58 |
+
ext = os.path.splitext(file_path)[1].lower()
|
59 |
+
|
60 |
+
if ext in ['.png', '.jpg', '.jpeg']:
|
61 |
+
return 'Not Supported'
|
62 |
+
else:
|
63 |
+
raise ValueError("Unsupported file format")
|
64 |
|
65 |
# Function for upscaling image using OpenCV's INTER_CUBIC
|
66 |
def upscale_image(image, scale=2):
|