dominiquebuford commited on
Commit
c25ef3c
·
1 Parent(s): a19569f

try new command

Browse files
Files changed (2) hide show
  1. app/app.py +17 -3
  2. requirements.txt +1 -0
app/app.py CHANGED
@@ -73,11 +73,25 @@ def upload():
73
  if data_url:
74
  # Remove header from base64 encoded image
75
  img_data = data_url.split(',')[1]
 
 
 
 
 
 
 
 
 
 
 
 
 
76
 
77
  # Save the image to a file
78
- image_path = os.path.join(app.config['UPLOAD_FOLDER'], f'image_{imageID}.png')
79
- with open( image_path,'wb') as f:
80
- f.write(base64.b64decode(img_data))
 
81
 
82
  if useGAN == False:
83
  answer = run_model_evaluation(image_path, useGan = False, imageID = imageID)
 
73
  if data_url:
74
  # Remove header from base64 encoded image
75
  img_data = data_url.split(',')[1]
76
+
77
+
78
+
79
+ # Decode the base64 string
80
+ image_data = base64.b64decode(img_data)
81
+
82
+ # Create a secure filename
83
+ filename = f'image_{imageID}.png'
84
+
85
+ # Upload the file to GCS
86
+ blob = bucket.blob(filename)
87
+ blob.upload_from_string(image_data, content_type='image/png')
88
+ blob.make_public()
89
 
90
  # Save the image to a file
91
+ #image_path = os.path.join(app.config['UPLOAD_FOLDER'], f'image_{imageID}.png')
92
+ #with open( image_path,'wb') as f:
93
+ #f.write(base64.b64decode(img_data))
94
+ image_path = blob.public_url
95
 
96
  if useGAN == False:
97
  answer = run_model_evaluation(image_path, useGan = False, imageID = imageID)
requirements.txt CHANGED
@@ -5,6 +5,7 @@ torchvision
5
  torchaudio
6
  tensorflow
7
  google-cloud-storage
 
8
  keras
9
  pandas
10
  gunicorn
 
5
  torchaudio
6
  tensorflow
7
  google-cloud-storage
8
+ google-auth
9
  keras
10
  pandas
11
  gunicorn