Tonic commited on
Commit
ce14d7b
·
1 Parent(s): 1a130ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -105,16 +105,12 @@ def _parse_text(text):
105
  text = "".join(lines)
106
  return text
107
 
108
- def save_image(image_file, uploaded_file_dir):
109
- upload_dir = Path(uploaded_file_dir) / "uploads"
110
- upload_dir.mkdir(parents=True, exist_ok=True)
111
  filename = secrets.token_hex(10) + Path(image_file.name).suffix
112
- file_path = upload_dir / filename
113
  with open(file_path, "wb") as f:
114
- if isinstance(image_file, gr.NamedString):
115
- f.write(image_file.value.encode())
116
- else:
117
- f.write(image_file.read())
118
  return str(file_path)
119
 
120
  def add_file(history, task_history, file):
 
105
  text = "".join(lines)
106
  return text
107
 
108
+ def save_image(image_file, upload_dir):
109
+ Path(upload_dir).mkdir(parents=True, exist_ok=True)
 
110
  filename = secrets.token_hex(10) + Path(image_file.name).suffix
111
+ file_path = Path(upload_dir) / filename
112
  with open(file_path, "wb") as f:
113
+ f.write(image_file.read())
 
 
 
114
  return str(file_path)
115
 
116
  def add_file(history, task_history, file):