Omnibus commited on
Commit
4246286
·
verified ·
1 Parent(s): 6330d91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -18
app.py CHANGED
@@ -104,7 +104,6 @@ def get_images():
104
  return html_out
105
 
106
  def make_animation():
107
- html_out=f"<style>{css}</style><div class='img_box'>"
108
  get_url=f'{main_directory}images/animations/'
109
  feed1 = requests.get(get_url)
110
  spl = feed1.text.split("href=")
@@ -131,29 +130,22 @@ def make_animation():
131
  print(ea)
132
  urllib.request.urlretrieve(ea,f'tmp{i}.png')
133
  frames.append(f'tmp{i}.png')
134
- #frames.append(Image.open(f'tmp{i}.png'))
135
- #frame_one = frames[0]
136
- #filename1=f'{uuid.uuid4()}.gif'
137
- #filename=os.path.abspath(filename1)
138
- print("**************")
139
- #print(filename)
140
- fps=10
141
  uid=uuid.uuid4()
142
  clip = ic.ImageSequenceClip(frames, fps = fps)
143
  clip.to_gif(f"{uid}.gif",fps=fps)
144
  files_out.append(f'{uid}.gif')
145
- #current_file_path = Path(f"{uid}.gif").resolve()
146
- #print(current_file_path)
147
- #relative_path = "path/to/file"
148
- #absolute_path = (current_file_path.parent / ".." / ".." / "gradio").resolve()
149
- #print(absolute_path)
150
-
151
- #frame_one.save(filename, format="GIF", append_images=frames, save_all=True, duration=100, loop=0)
152
- html_out+=f'<div class="img_class"><img src="{current_file_path}"></div>'
153
  except Exception as e:
154
  print(e)
 
 
 
 
 
 
 
155
  html_out+='</div>'
156
- return html_out,files_out
157
 
158
  def run():
159
  out=make_tree()
@@ -180,7 +172,7 @@ with gr.Blocks() as app:
180
  ###### Images ##########
181
 
182
  load_btn.click(load_json,[drop1,drop2,drop3,drop4],[html_raw,links])
183
- anim_btn.click(make_animation,None,[anim_out,file_out])
184
 
185
  ####### Raw ############
186
  drop1.change(make_tree,drop1,[drop2])
 
104
  return html_out
105
 
106
  def make_animation():
 
107
  get_url=f'{main_directory}images/animations/'
108
  feed1 = requests.get(get_url)
109
  spl = feed1.text.split("href=")
 
130
  print(ea)
131
  urllib.request.urlretrieve(ea,f'tmp{i}.png')
132
  frames.append(f'tmp{i}.png')
133
+ fps=60
 
 
 
 
 
 
134
  uid=uuid.uuid4()
135
  clip = ic.ImageSequenceClip(frames, fps = fps)
136
  clip.to_gif(f"{uid}.gif",fps=fps)
137
  files_out.append(f'{uid}.gif')
 
 
 
 
 
 
 
 
138
  except Exception as e:
139
  print(e)
140
+ return files_out
141
+
142
+ def make_html(inp_files):
143
+ html_out=f"<style>{css}</style><div class='img_box'>"
144
+ for ea in inp_files:
145
+ print(ea)
146
+ html_out+=f'<div class="img_class"><img src="{ea}"></div>'
147
  html_out+='</div>'
148
+ return html_out
149
 
150
  def run():
151
  out=make_tree()
 
172
  ###### Images ##########
173
 
174
  load_btn.click(load_json,[drop1,drop2,drop3,drop4],[html_raw,links])
175
+ anim_btn.click(make_animation,None,[file_out]).then(make_html,file_out,anim_out)
176
 
177
  ####### Raw ############
178
  drop1.change(make_tree,drop1,[drop2])