DurgaDeepak commited on
Commit
b0ea65c
·
verified ·
1 Parent(s): a67a089

Update core/input_handler.py

Browse files
Files changed (1) hide show
  1. core/input_handler.py +7 -9
core/input_handler.py CHANGED
@@ -121,21 +121,19 @@ def validate_video(path):
121
  return False, str(e)
122
 
123
  def show_preview_from_upload(files):
124
- if not files:
125
  return gr.update(visible=False), gr.update(visible=False)
126
-
127
- file = files[0]
128
- name = file.name.lower()
129
- if name.endswith((".png", ".jpg", ".jpeg", ".webp")):
130
- return gr.update(value=file, visible=True), gr.update(visible=False)
131
- elif name.endswith((".mp4", ".mov", ".avi")):
132
- return gr.update(visible=False), gr.update(value=file, visible=True)
133
  return gr.update(visible=False), gr.update(visible=False)
134
 
 
135
  def show_preview_from_url(url):
136
  if not url:
137
  return gr.update(visible=False), gr.update(visible=False)
138
-
139
  url = url.strip().lower()
140
  if url.endswith((".png", ".jpg", ".jpeg", ".webp")):
141
  return gr.update(value=url, visible=True), gr.update(visible=False)
 
121
  return False, str(e)
122
 
123
  def show_preview_from_upload(files):
124
+ if not files or len(files) == 0:
125
  return gr.update(visible=False), gr.update(visible=False)
126
+ file_path = files[0].name # Use .name to get the temp file path
127
+ if file_path.endswith((".png", ".jpg", ".jpeg", ".webp")):
128
+ return gr.update(value=file_path, visible=True), gr.update(visible=False)
129
+ elif file_path.endswith((".mp4", ".mov", ".avi")):
130
+ return gr.update(visible=False), gr.update(value=file_path, visible=True)
 
 
131
  return gr.update(visible=False), gr.update(visible=False)
132
 
133
+
134
  def show_preview_from_url(url):
135
  if not url:
136
  return gr.update(visible=False), gr.update(visible=False)
 
137
  url = url.strip().lower()
138
  if url.endswith((".png", ".jpg", ".jpeg", ".webp")):
139
  return gr.update(value=url, visible=True), gr.update(visible=False)