2022-12-26 21:01:27 -07:00
|
|
|
|
|
|
|
import streamlit as st
|
|
|
|
from PIL import Image
|
|
|
|
|
|
|
|
from riffusion.util.image_util import exif_from_image
|
|
|
|
|
|
|
|
|
|
|
|
def render_image_to_audio() -> None:
|
|
|
|
image_file = st.sidebar.file_uploader(
|
|
|
|
"Upload a file",
|
|
|
|
type=["png", "jpg", "jpeg"],
|
|
|
|
label_visibility="collapsed",
|
|
|
|
)
|
|
|
|
if not image_file:
|
|
|
|
st.info("Upload an image file to get started")
|
|
|
|
return
|
|
|
|
|
|
|
|
image = Image.open(image_file)
|
|
|
|
st.image(image)
|
|
|
|
|
|
|
|
exif = exif_from_image(image)
|
|
|
|
st.write("Exif data:")
|
|
|
|
st.write(exif)
|
|
|
|
|
2022-12-26 22:03:30 -07:00
|
|
|
# device = "cuda"
|
2022-12-26 21:01:27 -07:00
|
|
|
|
2022-12-26 22:03:30 -07:00
|
|
|
# try:
|
|
|
|
# params = SpectrogramParams.from_exif(exif=image.getexif())
|
|
|
|
# except KeyError:
|
|
|
|
# st.warning("Could not find spectrogram parameters in exif data. Using defaults.")
|
|
|
|
# params = SpectrogramParams()
|
2022-12-26 21:01:27 -07:00
|
|
|
|
|
|
|
# segment = streamlit_util.audio_from_spectrogram_image(
|
|
|
|
# image=image,
|
|
|
|
# params=params,
|
|
|
|
# device=device,
|
|
|
|
# )
|
|
|
|
|
|
|
|
# mp3_bytes = io.BytesIO()
|
|
|
|
# segment.export(mp3_bytes, format="mp3")
|
|
|
|
# mp3_bytes.seek(0)
|
|
|
|
|
|
|
|
# st.audio(mp3_bytes)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
render_image_to_audio()
|