Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -419,7 +419,7 @@ def process_video_and_audio(video_input):
|
|
| 419 |
# Display frames and transcript
|
| 420 |
st.markdown("### Video Frames")
|
| 421 |
for frame_b64 in base64Frames:
|
| 422 |
-
st.image(f"data:image/jpg;base64,{frame_b64}",
|
| 423 |
st.markdown("### Audio Transcription")
|
| 424 |
st.write(transcription.text)
|
| 425 |
return transcription.text
|
|
@@ -472,9 +472,9 @@ def integrated_workflow():
|
|
| 472 |
mode = st.selectbox("Snapshot Mode", ["single", "twopage", "allpages"])
|
| 473 |
snapshots = asyncio.run(process_pdf_snapshot(file_path, mode))
|
| 474 |
for snapshot in snapshots:
|
| 475 |
-
st.image(Image.open(snapshot), caption=f"Snapshot: {snapshot}",
|
| 476 |
else:
|
| 477 |
-
st.image(Image.open(file_path), caption="Uploaded Image",
|
| 478 |
# Run OCR on the file (using first page or the image itself)
|
| 479 |
if st.button("Run OCR on File"):
|
| 480 |
if uploaded_file.type == "application/pdf":
|
|
@@ -520,7 +520,7 @@ def update_gallery():
|
|
| 520 |
for idx, file in enumerate(all_files[:st.session_state.get('gallery_size', 5)]):
|
| 521 |
with cols[idx % 2]:
|
| 522 |
if file.endswith('.png'):
|
| 523 |
-
st.image(Image.open(file), caption=os.path.basename(file),
|
| 524 |
else:
|
| 525 |
st.markdown(os.path.basename(file))
|
| 526 |
if st.button("Delete "+os.path.basename(file), key="del_"+file):
|
|
@@ -563,7 +563,7 @@ with tabs[1]:
|
|
| 563 |
filename = generate_filename("cam0_snapshot", "png")
|
| 564 |
with open(filename, "wb") as f:
|
| 565 |
f.write(cam0_img.getvalue())
|
| 566 |
-
st.image(Image.open(filename), caption="Camera 0 Snapshot",
|
| 567 |
st.session_state.history.append(f"Captured {filename}")
|
| 568 |
with col2:
|
| 569 |
cam1_img = st.camera_input("Take a picture - Cam 1", key="cam1")
|
|
@@ -571,7 +571,7 @@ with tabs[1]:
|
|
| 571 |
filename = generate_filename("cam1_snapshot", "png")
|
| 572 |
with open(filename, "wb") as f:
|
| 573 |
f.write(cam1_img.getvalue())
|
| 574 |
-
st.image(Image.open(filename), caption="Camera 1 Snapshot",
|
| 575 |
st.session_state.history.append(f"Captured {filename}")
|
| 576 |
st.markdown("---")
|
| 577 |
st.subheader("Generate New Image with Diffusion")
|
|
@@ -579,7 +579,7 @@ with tabs[1]:
|
|
| 579 |
if st.button("Generate Image"):
|
| 580 |
output_file = generate_filename("gen_output", "png")
|
| 581 |
result_img = asyncio.run(process_image_gen(prompt_img, output_file))
|
| 582 |
-
st.image(result_img, caption="Generated Image",
|
| 583 |
|
| 584 |
# --- PDF & Documents Tab ---
|
| 585 |
with tabs[2]:
|
|
@@ -633,7 +633,7 @@ with tabs[3]:
|
|
| 633 |
image_file = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg"], key="chat_image")
|
| 634 |
if image_file:
|
| 635 |
image = Image.open(image_file)
|
| 636 |
-
st.image(image, caption="Uploaded Image",
|
| 637 |
response = process_image_with_prompt(image, text_prompt)
|
| 638 |
st.markdown(response)
|
| 639 |
elif mode == "Audio":
|
|
|
|
| 419 |
# Display frames and transcript
|
| 420 |
st.markdown("### Video Frames")
|
| 421 |
for frame_b64 in base64Frames:
|
| 422 |
+
st.image(f"data:image/jpg;base64,{frame_b64}", use_container_width=True)
|
| 423 |
st.markdown("### Audio Transcription")
|
| 424 |
st.write(transcription.text)
|
| 425 |
return transcription.text
|
|
|
|
| 472 |
mode = st.selectbox("Snapshot Mode", ["single", "twopage", "allpages"])
|
| 473 |
snapshots = asyncio.run(process_pdf_snapshot(file_path, mode))
|
| 474 |
for snapshot in snapshots:
|
| 475 |
+
st.image(Image.open(snapshot), caption=f"Snapshot: {snapshot}", use_container_width=True)
|
| 476 |
else:
|
| 477 |
+
st.image(Image.open(file_path), caption="Uploaded Image", use_container_width=True)
|
| 478 |
# Run OCR on the file (using first page or the image itself)
|
| 479 |
if st.button("Run OCR on File"):
|
| 480 |
if uploaded_file.type == "application/pdf":
|
|
|
|
| 520 |
for idx, file in enumerate(all_files[:st.session_state.get('gallery_size', 5)]):
|
| 521 |
with cols[idx % 2]:
|
| 522 |
if file.endswith('.png'):
|
| 523 |
+
st.image(Image.open(file), caption=os.path.basename(file), use_container_width=True)
|
| 524 |
else:
|
| 525 |
st.markdown(os.path.basename(file))
|
| 526 |
if st.button("Delete "+os.path.basename(file), key="del_"+file):
|
|
|
|
| 563 |
filename = generate_filename("cam0_snapshot", "png")
|
| 564 |
with open(filename, "wb") as f:
|
| 565 |
f.write(cam0_img.getvalue())
|
| 566 |
+
st.image(Image.open(filename), caption="Camera 0 Snapshot", use_container_width=True)
|
| 567 |
st.session_state.history.append(f"Captured {filename}")
|
| 568 |
with col2:
|
| 569 |
cam1_img = st.camera_input("Take a picture - Cam 1", key="cam1")
|
|
|
|
| 571 |
filename = generate_filename("cam1_snapshot", "png")
|
| 572 |
with open(filename, "wb") as f:
|
| 573 |
f.write(cam1_img.getvalue())
|
| 574 |
+
st.image(Image.open(filename), caption="Camera 1 Snapshot", use_container_width=True)
|
| 575 |
st.session_state.history.append(f"Captured {filename}")
|
| 576 |
st.markdown("---")
|
| 577 |
st.subheader("Generate New Image with Diffusion")
|
|
|
|
| 579 |
if st.button("Generate Image"):
|
| 580 |
output_file = generate_filename("gen_output", "png")
|
| 581 |
result_img = asyncio.run(process_image_gen(prompt_img, output_file))
|
| 582 |
+
st.image(result_img, caption="Generated Image", use_container_width=True)
|
| 583 |
|
| 584 |
# --- PDF & Documents Tab ---
|
| 585 |
with tabs[2]:
|
|
|
|
| 633 |
image_file = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg"], key="chat_image")
|
| 634 |
if image_file:
|
| 635 |
image = Image.open(image_file)
|
| 636 |
+
st.image(image, caption="Uploaded Image", use_container_width=True)
|
| 637 |
response = process_image_with_prompt(image, text_prompt)
|
| 638 |
st.markdown(response)
|
| 639 |
elif mode == "Audio":
|