Hammad712 commited on
Commit
942611a
·
verified ·
1 Parent(s): 7bbaa63

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -6,6 +6,8 @@ from io import BytesIO
6
  import requests
7
  import torch.nn as nn
8
  import os
 
 
9
 
10
  # Define the FeatureLoss class
11
  class FeatureLoss(nn.Module):
@@ -67,8 +69,10 @@ if not os.path.exists(model_file_path):
67
  f.write(response.content)
68
  st.success('Model downloaded successfully!')
69
 
70
- # Load the trained model
71
- learn = load_learner(model_file_path)
 
 
72
 
73
  # Input for image URL or path
74
  image_path_or_url = st.text_input("Enter image path or URL", "")
 
6
  import requests
7
  import torch.nn as nn
8
  import os
9
+ import tempfile
10
+ import shutil
11
 
12
  # Define the FeatureLoss class
13
  class FeatureLoss(nn.Module):
 
69
  f.write(response.content)
70
  st.success('Model downloaded successfully!')
71
 
72
+ # Create a temporary directory for the model
73
+ with tempfile.TemporaryDirectory() as tmpdirname:
74
+ shutil.move(model_file_path, os.path.join(tmpdirname, 'export.pkl'))
75
+ learn = load_learner(tmpdirname)
76
 
77
  # Input for image URL or path
78
  image_path_or_url = st.text_input("Enter image path or URL", "")