Download app.py from Bagda/BINDI: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/Bagda/BINDI/resolve/main/app.py
- Command line
-
hf download hf://spaces/Bagda/BINDI/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Bagda/BINDI/resolve/main/app.py
1.07 kB
| import streamlit as st | |
| import requests | |
| from PIL import Image | |
| from io import BytesIO | |
| st.set_page_config(page_title="DALLE Mini Thumbnail Generator") | |
| st.title("🖼️ Thumbnail Generator using DALL·E Mini") | |
| prompt = st.text_input("Enter your thumbnail prompt:", "Minecraft NOOB vs PRO Hardcore battle") | |
| if st.button("Generate"): | |
| with st.spinner("Generating Image..."): | |
| api_url = "https://api-inference.huggingface.co/models/dalle-mini/dalle-mini/mega-1-fp16:latest" | |
| headers = {"Authorization": "Bearer YOUR_HF_API_TOKEN"} # replace with real token | |
| response = requests.post(api_url, headers=headers, json={"inputs": prompt}) | |
| if response.status_code == 200: | |
| output = response.json() | |
| image_url = output["generated_images"][0] | |
| image_data = requests.get(image_url).content | |
| image = Image.open(BytesIO(image_data)) | |
| st.image(image, caption="Generated Thumbnail") | |
| st.success("Done!") | |
| else: | |
| st.error("❌ Failed to generate image. Try again later.") |