cagataydag commited on
Commit
c7b8eac
·
1 Parent(s): fe1798c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -11
app.py CHANGED
@@ -413,29 +413,36 @@ with blocks:
413
 
414
 
415
  def my_inference_function(image,text):
416
- img_dir = tempfile.mkdtemp()
417
 
418
  #img_path = os.path.join(img_dir, f"_112.jpeg")
419
- img_path ="/tmp/111_112.jpeg"
420
  #decodedData = base64.b64decode((image))
421
 
422
- print("----- my_inference_function img_path -----")
423
- print(img_path)
424
 
425
  # Write Image from Base64 File
426
  #imgFile = open(img_path, 'wb')
427
  #imgFile.write(decodedData)
428
  #imgFile.close()
429
 
430
- with open(img_path, "wb") as fh:
431
- fh.write(base64.urlsafe_b64decode(image))
432
 
433
- file = open(img_path, 'rb')
434
- encoded_data = file.read()
435
- file.close()
436
 
437
- print("----- my_inference_function encoded_data -----")
438
- print(encoded_data)
 
 
 
 
 
 
 
439
 
440
  return editor.predict(img_path,[text],edit_choices={'edit_type': 'None', 'pose': 0, 'smile': 0, 'gender': 0, 'age': 0, 'hair_length': 0, 'src_text': '', 'tar_text': '', 'alpha': 1, 'beta': 0.14})
441
 
 
413
 
414
 
415
  def my_inference_function(image,text):
416
+ #img_dir = tempfile.mkdtemp()
417
 
418
  #img_path = os.path.join(img_dir, f"_112.jpeg")
419
+ #img_path ="/tmp/111_112.jpeg"
420
  #decodedData = base64.b64decode((image))
421
 
422
+ #print("----- my_inference_function img_path -----")
423
+ #print(img_path)
424
 
425
  # Write Image from Base64 File
426
  #imgFile = open(img_path, 'wb')
427
  #imgFile.write(decodedData)
428
  #imgFile.close()
429
 
430
+ #with open(img_path, "wb") as fh:
431
+ # fh.write(base64.urlsafe_b64decode(image))
432
 
433
+ #file = open(img_path, 'rb')
434
+ #encoded_data = file.read()
435
+ #file.close()
436
 
437
+ temp = tempfile.NamedTemporaryFile()
438
+ temp.write(image)
439
+ print("Name of the file is:", temp.name)
440
+ temp.close()
441
+
442
+ img_path = temp.name
443
+
444
+ print("----- my_inference_function temp.read -----")
445
+ print(temp.read())
446
 
447
  return editor.predict(img_path,[text],edit_choices={'edit_type': 'None', 'pose': 0, 'smile': 0, 'gender': 0, 'age': 0, 'hair_length': 0, 'src_text': '', 'tar_text': '', 'alpha': 1, 'beta': 0.14})
448