wayandadang commited on
Commit
fdb53d2
1 Parent(s): 37e9e4f

update code

Browse files
Files changed (2) hide show
  1. ROC Curve.jpg +0 -0
  2. app.py +8 -0
ROC Curve.jpg CHANGED
app.py CHANGED
@@ -9,6 +9,7 @@ import requests
9
  from io import BytesIO
10
  from kan_linear import KANLinear
11
  import logging
 
12
 
13
  # Setup logging
14
  logging.basicConfig(level=logging.INFO)
@@ -46,6 +47,13 @@ class CustomImageLoadingError(Exception):
46
  def load_image_from_url(url):
47
  try:
48
  logging.info(f"Loading image from URL: {url}")
 
 
 
 
 
 
 
49
  response = requests.get(url)
50
  response.raise_for_status() # Check if the request was successful
51
 
 
9
  from io import BytesIO
10
  from kan_linear import KANLinear
11
  import logging
12
+ import os
13
 
14
  # Setup logging
15
  logging.basicConfig(level=logging.INFO)
 
47
  def load_image_from_url(url):
48
  try:
49
  logging.info(f"Loading image from URL: {url}")
50
+
51
+ # Check the file extension
52
+ valid_extensions = ['jpg', 'jpeg', 'png', 'webp']
53
+ file_extension = os.path.splitext(url)[1][1:].lower()
54
+ if file_extension not in valid_extensions:
55
+ raise CustomImageLoadingError(f"URL does not point to an image with a valid extension: {file_extension}")
56
+
57
  response = requests.get(url)
58
  response.raise_for_status() # Check if the request was successful
59