aiqcamp / app.py
arxivgpt kim
Update app.py
853931d verified
raw
history blame contribute delete
No virus
17.4 kB
import streamlit as st
import requests
import streamlit.components.v1 as components
from gtts import gTTS
from gtts.lang import tts_langs
from io import BytesIO
import os
# νŽ˜μ΄μ§€ μ„€μ •
st.set_page_config(page_title="ViDraft", layout="wide")
# μ‚¬μ΄λ“œλ°” 타이틀 μ„€μ •
st.sidebar.title("ViDraft")
# 메뉴 및 ν•˜μœ„ 메뉴 μ •μ˜
menus = {
"Home": [],
"BEST": ["Face Swap", "Image Matching", "Face Avatar", "Zeroshot Voice", "HOT"],
"Free Stock": ["Template Video", "Search Video", "Search Image"],
"Image": ["Face Swap", "Remove Background", "Compositing", "Image Matching", "URL Screenshot"],
"Video": ["Face Avatar", "Remove Background", "Compositing"],
"Sound": ["TTS(Voice)" ,"Zeroshot Voice","Image SFX", "Video SFX","Image Music", "Video Music"]
}
# μ„Έμ…˜ μƒνƒœ μ΄ˆκΈ°ν™”
if 'current_menu' not in st.session_state:
st.session_state['current_menu'] = 'Home'
if 'current_sub_menu' not in st.session_state:
st.session_state['current_sub_menu'] = ''
# 메인 메뉴 선택
selected_menu = st.sidebar.selectbox("Menu", list(menus.keys()), key='main_menu')
st.session_state['current_menu'] = selected_menu
# ν•˜μœ„ 메뉴 선택 (ν•΄λ‹Ήλ˜λŠ” 경우)
if selected_menu in menus:
selected_sub_menu = st.sidebar.selectbox("Sub Menu", [""] + menus[selected_menu], key=f'sub_menu_{selected_menu}')
st.session_state['current_sub_menu'] = selected_sub_menu
else:
st.session_state['current_sub_menu'] = ''
# 'Sound' λ©”λ‰΄μ˜ 'TTS(Voice)' 선택 μ‹œ
if selected_menu == "Sound" and selected_sub_menu == "TTS(Voice)":
st.header("Text-to-Speech")
# ν…μŠ€νŠΈ μž…λ ₯
text = st.text_area("Enter text to synthesize", "Hello, welcome to ViDraft TTS service.")
# μ§€μ›λ˜λŠ” μ–Έμ–΄ λͺ©λ‘μ„ λΆˆλŸ¬μ˜΅λ‹ˆλ‹€.
languages_dict = tts_langs()
# ISO 639-1 ν‘œμ€€μ— 따라 두 κΈ€μž μ½”λ“œλ₯Ό 가진 μ–Έμ–΄λ§Œ 필터링
two_letter_languages = {code: lang for code, lang in languages_dict.items() if len(code) == 2}
# μ–Έμ–΄ 선택을 μœ„ν•œ selectboxλ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
selected_language_code = st.selectbox(
"Choose Language",
options=list(two_letter_languages.keys()),
format_func=lambda x: f"{two_letter_languages[x]} ({x})",
index=list(two_letter_languages.keys()).index('en') # 'en'을 κΈ°λ³Έ μ–Έμ–΄λ‘œ μ„€μ •
)
# 'Synthesize' λ²„νŠΌ
if st.button("Synthesize"):
if text:
try:
# μ„ νƒλœ μ–Έμ–΄λ‘œ gTTS 객체 생성
tts = gTTS(text=text, lang=selected_language_code, slow=False)
audio_file = BytesIO()
tts.write_to_fp(audio_file)
audio_file.seek(0)
# μƒμ„±λœ μ˜€λ””μ˜€ νŒŒμΌμ„ μž¬μƒ
st.audio(audio_file, format="audio/mp3")
except Exception as e:
st.error(f"Error: {e}")
else:
st.warning("Please enter some text to synthesize.")
# Pexels API ν‚€ μ„€μ •
PEXELS_API_KEY = "5woz23MGx1QrSY0WHFb0BRi29JvbXPu97Hg0xnklYgHUI8G0w23FKH62"
def search_images(keyword, per_page=80):
"""이미지 검색 ν•¨μˆ˜"""
url = f"https://api.pexels.com/v1/search?query={keyword}&per_page={per_page}"
headers = {"Authorization": PEXELS_API_KEY}
response = requests.get(url, headers=headers).json()
images = []
if 'photos' in response:
for photo in response['photos']:
images.append(photo['src']['original'])
return images
def search_videos(keyword, per_page=80):
"""λΉ„λ””μ˜€ 검색 ν•¨μˆ˜"""
url = f"https://api.pexels.com/videos/search?query={keyword}&per_page={per_page}"
headers = {"Authorization": PEXELS_API_KEY}
response = requests.get(url, headers=headers).json()
videos = []
if 'videos' in response:
for video in response['videos']:
videos.append(video['video_files'][0]['link'])
return videos
# 'Search Image' 선택 μ‹œ
if selected_menu == "Free Stock" and st.session_state['current_sub_menu'] == "Search Image":
keyword = st.text_input("Enter a keyword to search for images")
if keyword:
images = search_images(keyword)
cols = st.columns(3) # 3μ—΄λ‘œ 이미지 ν‘œμ‹œ
for idx, img in enumerate(images):
with cols[idx % 3]:
st.image(img)
# 'Search Video' 선택 μ‹œ
if selected_menu == "Free Stock" and st.session_state['current_sub_menu'] == "Search Video":
keyword = st.text_input("Enter a keyword to search for videos")
if keyword:
videos = search_videos(keyword)
cols = st.columns(3) # 3μ—΄λ‘œ λΉ„λ””μ˜€ ν‘œμ‹œ
for idx, video in enumerate(videos):
with cols[idx % 3]:
st.video(video)
# 'Image' λ©”λ‰΄μ—μ„œ 'Remove Background' 선택 μ‹œ
if selected_menu == "Image" and st.session_state['current_sub_menu'] == "Remove Background":
st.header("Remove Background")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://arxivgpt-vidnuki.hf.space", width=None, height=768, scrolling=True)
# 'Image' λ©”λ‰΄μ—μ„œ 'Compositing' 선택 μ‹œ
if selected_menu == "Image" and st.session_state['current_sub_menu'] == "Compositing":
st.header("Compositing")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://arxivgpt-vidistudio.hf.space", width=None, height=1800, scrolling=True)
# 'Image' λ©”λ‰΄μ—μ„œ 'Face Swap' 선택 μ‹œ
if selected_menu == "Image" and st.session_state['current_sub_menu'] == "Face Swap":
st.header("Face Swap")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://seawolf2357-vidifs.hf.space", width=None, height=1800, scrolling=True)
# 'video' λ©”λ‰΄μ—μ„œ 'Compositing' 선택 μ‹œ
if selected_menu == "Video" and st.session_state['current_sub_menu'] == "Compositing":
st.header("Compositing")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://arxivgpt-vidvstudio.hf.space", width=None, height=1800, scrolling=True)
# 'video' λ©”λ‰΄μ—μ„œ 'Compositing' 선택 μ‹œ
if selected_menu == "Video" and st.session_state['current_sub_menu'] == "Remove Background":
st.header("Remove Background")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://arxivgpt-vidvback.hf.space", width=None, height=1800, scrolling=True)
# 'sound' λ©”λ‰΄μ—μ„œ 'SFX' 선택 μ‹œ
if selected_menu == "Sound" and st.session_state['current_sub_menu'] == "Image SFX":
st.header("Image SFX")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://arxivgpt-vidisfx.hf.space", width=None, height=1800, scrolling=True)
# 'sound' λ©”λ‰΄μ—μ„œ 'SFX' 선택 μ‹œ
if selected_menu == "Sound" and st.session_state['current_sub_menu'] == "Video SFX":
st.header("Video SFX")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://fffiloni-Video-to-SoundFX.hf.space", width=None, height=1800, scrolling=True)
# 'Image' λ©”λ‰΄μ—μ„œ 'Image Matching' 선택 μ‹œ
if selected_menu == "Image" and st.session_state['current_sub_menu'] == "Image Matching":
st.header("Image Matching")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://seawolf2357-vidimatch.hf.space", width=None, height=1800, scrolling=True)
# 'Image' λ©”λ‰΄μ—μ„œ 'URL Screenshot' 선택 μ‹œ
if selected_menu == "Image" and st.session_state['current_sub_menu'] == "URL Screenshot":
st.header("URL Screenshot")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://arxivgpt-vidiscreen.hf.space", width=None, height=1800, scrolling=True)
# 'sound' λ©”λ‰΄μ—μ„œ 'Video Music' 선택 μ‹œ
if selected_menu == "Sound" and st.session_state['current_sub_menu'] == "Video Music":
st.header("Video Music")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://arxivgpt-vidsm.hf.space", width=None, height=1800, scrolling=True)
# 'sound' λ©”λ‰΄μ—μ„œ 'Image Music' 선택 μ‹œ
if selected_menu == "Sound" and st.session_state['current_sub_menu'] == "Image Music":
st.header("Image Music")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://arxivgpt-vidim.hf.space", width=None, height=1800, scrolling=True)
# 'BEST' λ©”λ‰΄μ—μ„œ 'Face Swap' 선택 μ‹œ
if selected_menu == "BEST" and st.session_state['current_sub_menu'] == "Face Swap":
st.header("Face Swap")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://seawolf2357-vidifs.hf.space", width=None, height=1800, scrolling=True)
# 'BEST' λ©”λ‰΄μ—μ„œ 'Image Matching' 선택 μ‹œ
if selected_menu == "BEST" and st.session_state['current_sub_menu'] == "Image Matching":
st.header("Image Matching")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://seawolf2357-vidimatch.hf.space", width=None, height=1800, scrolling=True)
# 'BEST' λ©”λ‰΄μ—μ„œ 'HOT' 선택 μ‹œ
if selected_menu == "BEST" and st.session_state['current_sub_menu'] == "HOT":
st.header("Image & Video EDIT")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://seawolf2357-vidraftgpu.hf.space", width=None, height=1800, scrolling=True)
# 'video' λ©”λ‰΄μ—μ„œ 'Face Avatar' 선택 μ‹œ
if selected_menu == "Video" and st.session_state['current_sub_menu'] == "Face Avatar":
st.header("Remove Background")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://arxivgpt-face.hf.space", width=None, height=1800, scrolling=True)
# 'BEST' λ©”λ‰΄μ—μ„œ 'Face Avatar' 선택 μ‹œ
if selected_menu == "BEST" and st.session_state['current_sub_menu'] == "Face Avatar":
st.header("Remove Background")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://arxivgpt-face.hf.space", width=None, height=1800, scrolling=True)
# 'sound' λ©”λ‰΄μ—μ„œ 'Zeroshot Voice' 선택 μ‹œ
if selected_menu == "Sound" and st.session_state['current_sub_menu'] == "Zeroshot Voice":
st.header("Zeroshot Voice")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://seawolf2357-vidsvclo.hf.space", width=None, height=1800, scrolling=True)
# 'BEST' λ©”λ‰΄μ—μ„œ 'Zeroshot Voice' 선택 μ‹œ
if selected_menu == "BEST" and st.session_state['current_sub_menu'] == "Zeroshot Voice":
st.header("Zeroshot Voice")
# iframe을 μ‚¬μš©ν•˜μ—¬ μ™ΈλΆ€ URL μž„λ² λ“œ
components.iframe("https://seawolf2357-vidsvclo.hf.space", width=None, height=1800, scrolling=True)
# 'Home' νŽ˜μ΄μ§€ ν‘œμ‹œ
if selected_menu == "Home":
st.image("banner2.jpg", use_column_width=True)
st.header("Welcome to ViDraft")
st.header("'Create Contents, ViDraft Value-UP'")
# ν™˜μ˜ λ©”μ‹œμ§€ 및 μ„œλΉ„μŠ€ μ„€λͺ…
welcome_text = """
Welcome to our dynamic platform, where creativity meets technology across a vast spectrum of multimedia services. Our service offers an extensive array of options for every multimedia need:
- **Video Template (OpenAI SORA)**: "Discover a world of creativity with OpenAI SORA's Video Templates. From captivating intros to engaging outros, our AI-powered templates transform your visions into cinematic realities."
- **Free Stock: Video Search**: "Dive into an expansive ocean of premium stock videos. Whether it's breathtaking landscapes or dynamic urban life, find the perfect clip to elevate your project, all at your fingertips."
- **Free Stock: Image Search**: "Explore a vast gallery of stunning images, curated to perfection. From the serene to the spectacular, uncover the ideal visual complement for your next creative endeavor."
- **Multilingual Text to Speech(TTS)**: "Bring your content to life in any language with our Multilingual Text to Speech technology. Experience seamless, natural-sounding voices that captivate your audience, no matter where they are."
- **Remove Image Background**: "Eradicate distractions and focus on what matters. Our AI swiftly removes any background, offering you a clean slate to unleash your creativity or perfectly blend your subject into new environments."
- **Remove Video Background**: "Transform your videos with the ability to remove and replace backgrounds effortlessly. Engage your audience with stunning visuals, no green screen required."
- **Video Compositing**: "Merge reality with imagination. Our Video Compositing technology seamlessly integrates various elements into your footage, creating a cohesive and visually stunning masterpiece."
- **Image Compositing**: "Elevate your images to art. Combine multiple elements with unparalleled precision, crafting compositions that tell a story, evoke emotions, or simply astound."
- **Face Swap Image**: "Step into a new identity or bring historical figures to life. Our Face Swap technology allows you to seamlessly transpose faces in images, unlocking endless creative possibilities."
- **Image SFX**: "Enhance your images with special effects that captivate. From subtle enhancements to dramatic transformations, our Image SFX tools let your creativity run wild."
- **Video SFX**: "Elevate your videos with extraordinary special effects. Whether you're creating an action-packed adventure or a serene landscape, our Video SFX library brings your vision to life."
- **Image Matching**: "Unveil the synergy between visuals with our Image Matching technology. Let AI seamlessly analyze and match disparate images, bridging the gap between creativity and coherence."
- **Remote URL Screenshot**: "Capture the essence of any website instantly with Remote URL Screenshot. Simply input a URL and let our system fetch and present a crisp snapshot of the site's main page, effortlessly."
- **Image to Music**: "Elevate your image to a symphonic level with image to Music. Upload any footage and witness as our AI discerns the essence of your visuals, crafting a harmonious soundtrack tailored specifically to enhance your video. Seamlessly integrated, the result is a beautifully augmented video experience, enriched with its own unique, AI-generated music."
- **Video to Music**: "Elevate your videos to a symphonic level with Video to Music. Upload any footage and witness as our AI discerns the essence of your visuals, crafting a harmonious soundtrack tailored specifically to enhance your video. Seamlessly integrated, the result is a beautifully augmented video experience, enriched with its own unique, AI-generated music."
Join us to transform your creative ideas into reality with cutting-edge technology designed for creators, by creators.
- Contact: arxivgpt@gmail.com *Powered by ArXivGPT, Huggingface, Gradio, Streamlit
"""
st.write(welcome_text)
# 이미지듀을 ν•œ 쀄에 3μž₯μ”© 배치
image_files = [
"ViDraft-Video-Templet.png",
"ViDraft-Video-search.png",
"ViDraft-Image-search.png",
"ViDraft-TTS.png",
"ViDraft-image-remove background.png",
"ViDraft-video-remove-back.png",
"ViDraft-video-comp.png",
"ViDraft-image-comp.png",
"ViDraft-image-face swap.png",
"ViDraft-image-sfx.png",
"ViDraft-video-sfx.png",
"ViDraft-image-screen.png",
"ViDraft-image-match.png",
"ViDraft-sound-music.png",
"ViDraft-image-music.png"
]
image_texts = [
"Video Template(OpenAI SORA)",
"Free Stock: Video Search",
"Free Stock: Image Search",
"Multilingual Text to Speech(TTS)",
"Remove image background",
"Remove Video background",
"Video Compositing",
"Image Compositing",
"Face Swap Image",
"Image SFX",
"Video SFX",
"Remote URL Screenshot",
"Image Matching",
"Video to Music",
"Image to Music"
]
for i in range(0, len(image_files), 3):
cols = st.columns(3)
for idx, col in enumerate(cols):
if i + idx < len(image_files):
col.image(image_files[i + idx], use_column_width=True)
col.markdown(f"<div style='text-align: center; font-weight: bold; font-size: 20px;'>{image_texts[i + idx]}</div>", unsafe_allow_html=True)
elif selected_menu == "Free Stock":
# 'Free Stock' 메뉴 선택 μ‹œ 처리 둜직
if st.session_state['current_sub_menu'] == "Template Video":
st.header("Template Videos")
st.write("Explore a variety of video templates crafted with the innovative technology of OpenAI SORA. Dive into an immersive experience with samples generated by the cutting-edge AI, showcasing the potential to transform your creative ideas into captivating visual stories.")
# λΉ„λ””μ˜€ 파일 경둜 μ„€μ • 및 λΉ„λ””μ˜€ ν‘œμ‹œ 둜직
video_files = ["ex1.mp4", "ex2.mp4", "ex3.mp4", "ex4.mp4", "ex5.mp4", "ex6.mp4", "ex7.mp4", "ex8.mp4", "ex9.mp4", "ex10.mp4", "ex11.mp4", "ex12.mp4", "ex13.mp4", "ex14.mp4", "ex15.mp4", "ex16.mp4", "ex17.mp4", "ex18.mp4"]
# 가러리 ν˜•νƒœλ‘œ λΉ„λ””μ˜€ ν‘œμ‹œ
cols = st.columns(2) # 2개의 μ—΄λ‘œ λ„“κ²Œ 배치
for index, video_file in enumerate(video_files):
with cols[index % 2]:
st.video(video_file)
# 'Scripts' 메뉴 선택 μ‹œ 처리 둜직
elif selected_menu == "Scripts":
st.header("Scripts")
st.write("Script writing tools and resources.")