Spaces:
Build error
Build error
Update app.py
Browse files98 unmodified lines9910010110210310410510698 unmodified linesmodel2.load_state_dict(torch.load('model2.pth', map_location=torch.device('cpu')))model2.eval() # Set the model to evaluation mode# 🖼️ Function to process the image and create line drawingdef predict(input_img, ver):# Open the image and get its original sizeoriginal_img = Image.open(input_img)original_size = original_img.size98 unmodified lines9910010110210310410510610710810911011111211311411511611711811912012198 unmodified linesmodel2.load_state_dict(torch.load('model2.pth', map_location=torch.device('cpu')))model2.eval() # Set the model to evaluation modedef download_image(url, save_path="temp_image.png"):"""Download an image from a URL and save it locally."""response = requests.get(url)if response.status_code == 200:with open(save_path, "wb") as f:f.write(response.content)return save_pathelse:raise Exception(f"Failed to download image: {response.status_code}")# 🖼️ Function to process the image and create line drawingdef predict(input_img, ver):if isinstance(input_img, str) and input_img.startswith("http"):input_img = download_image(input_img)# Open the image and get its original sizeoriginal_img = Image.open(input_img)original_size = original_img.size
app.py+15