Spaces:
Running
Running
File size: 2,842 Bytes
9100260 08c4577 9100260 c014942 9100260 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
import streamlit as st
import os
from core import process_header_image
def main():
st.markdown("""
<div align="center">
# Pic-to-Header

[](https://github.com/Sunwood-ai-labs/pic-to-header/blob/main/LICENSE)
[](https://github.com/Sunwood-ai-labs/pic-to-header/stargazers)
[](https://github.com/Sunwood-ai-labs/pic-to-header/issues)



</div>
Pic-to-Headerγ―γγγΉγ―η»εγ¨ε
₯εη»εγδ½Ώη¨γγ¦γγγγΌη»εγηζγγPythonγ’γγͺγ±γΌγ·γ§γ³γ§γγ
""", unsafe_allow_html=True)
st.write("γγΉγ―η»εγ¨ε
₯εη»εγγ’γγγγΌγγγ¦γγγγγΌη»εγηζγγΎγγ")
input_image = st.file_uploader("ε
₯εη»εγγ’γγγγΌγ", type=["png", "jpg", "jpeg"])
mask_image = st.file_uploader("γγΉγ―η»εγγ’γγγγΌγ", type=["png", "jpg", "jpeg"])
if input_image is not None and mask_image is not None:
if st.button("γγγγΌη»εγηζ"):
# δΈζγγ‘γ€γ«γ¨γγ¦δΏε
input_path = f"temp_input.{input_image.name.split('.')[-1]}"
mask_path = f"temp_mask.{mask_image.name.split('.')[-1]}"
output_path = "output_header.png"
with open(input_path, "wb") as f:
f.write(input_image.getbuffer())
with open(mask_path, "wb") as f:
f.write(mask_image.getbuffer())
# η»εε¦η
process_header_image(input_path, mask_path, output_path)
# η΅ζγ葨瀺
st.image(output_path, caption="ηζγγγγγγγΌη»ε")
# γγ¦γ³γγΌγγγΏγ³γθΏ½ε
with open(output_path, "rb") as file:
btn = st.download_button(
label="γγγγΌη»εγγγ¦γ³γγΌγ",
data=file,
file_name="header_image.png",
mime="image/png"
)
# δΈζγγ‘γ€γ«γει€
os.remove(input_path)
os.remove(mask_path)
os.remove(output_path)
if __name__ == "__main__":
main()
|