{"id":28759977,"url":"https://github.com/bchachar/image-generation","last_synced_at":"2026-04-13T21:05:13.700Z","repository":{"id":293866473,"uuid":"985344291","full_name":"bchachar/image-generation","owner":"bchachar","description":"A Streamlit app for generating AI images using Stable Diffusion with prompt similarity scoring and image gallery.","archived":false,"fork":false,"pushed_at":"2025-05-17T15:43:22.000Z","size":20195,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-17T06:01:56.585Z","etag":null,"topics":["artificial-intelligence","clip","image-generation","sqlalchemy","stable-diffusion","streamlit"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bchachar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-17T15:07:46.000Z","updated_at":"2025-05-17T17:03:41.000Z","dependencies_parsed_at":"2025-05-18T00:30:36.098Z","dependency_job_id":null,"html_url":"https://github.com/bchachar/image-generation","commit_stats":null,"previous_names":["bchachar/image-generation"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bchachar/image-generation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bchachar%2Fimage-generation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bchachar%2Fimage-generation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bchachar%2Fimage-generation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bchachar%2Fimage-generation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bchachar","download_url":"https://codeload.github.com/bchachar/image-generation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bchachar%2Fimage-generation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260444045,"owners_count":23010128,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","clip","image-generation","sqlalchemy","stable-diffusion","streamlit"],"created_at":"2025-06-17T06:00:34.558Z","updated_at":"2026-04-13T21:05:13.641Z","avatar_url":"https://github.com/bchachar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔠 AI Image Generator with Stable Diffusion + CLIP Evaluation\n\nThis Streamlit web app allows you to generate images using various pre-trained **Stable Diffusion** models and evaluates the generated image against the input prompt using **CLIP similarity scoring**. The generated images, their prompts, model used, and similarity scores are saved in a SQLite database and displayed in a paginated gallery and sidebar history.\n\n---\n![App Screenshot](generated_images/front.png)\n---\n## 📸 Features\n\n* 🔥 Choose from multiple Stable Diffusion models (via Hugging Face)\n* 🖼️ Generate high-quality AI images from text prompts\n* 📂 Saves each image, prompt, and model info into a local SQLite database\n* 🧠 Evaluates image-to-prompt similarity using OpenAI's CLIP model\n* 🗝️ Gallery view with pagination and prompt/model/similarity display\n* 📜 Sidebar shows recent image history\n* 🛩️ Clear all history with a single click\n\n---\n\n## 🚀 Getting Started\n\n### 1. Clone the Repository\n\n```bash\ngit clone https://github.com/bchachar/image-generation.git\ncd image-generation\n```\n\n### 2. Set Up a Virtual Environment (recommended)\n\n```bash\npython3 -m venv .venv\nsource .venv/bin/activate  # On Windows: .venv\\Scripts\\activate\n```\n\n### 3. Install Dependencies\n\n```bash\npip install -r requirements.txt\n```\n\n\u003e You need to have PyTorch installed with GPU support (`torch.cuda.is_available()`) for best performance.\n\n### 4. Run the App\n\n```bash\nstreamlit run app.py\n```\n\n---\n\n## 📆 Requirements\n\n```txt\nstreamlit\ntransformers\ntorch\naccelerate\nscipy\nsafetensors\ndiffusers\nPillow\nsqlalchemy\n```\n\n\n---\n\n## 💡 How It Works\n\n1. You enter a **prompt** and select a **Stable Diffusion model**.\n2. The app generates an image using the selected model.\n3. The image is evaluated with OpenAI's **CLIP** model to determine how well it matches the prompt.\n4. The image, prompt, model name, and similarity score are saved in `history.db`.\n5. The gallery displays the most recent images with prompt, model name, and similarity.\n\n### 🧠 CLIP Similarity\n\nWe use OpenAI’s CLIP model (`ViT-B/32`) to compute the cosine similarity between the prompt and generated image. This gives a percentage score (0–100) indicating how well the image matches the text prompt.\n\n---\n\n## 📁 Folder Structure\n\n```\n.\n├── app.py              # Streamlit app\n├── requirements.txt    # Python dependencies\n├── history.db          # SQLite DB (auto-created)\n├── generated_images/   # Folder for saved images\n└── README.md           # You're here!\n```\n\n---\n\n## Clear History\n\nUse the **\"Clear History\"** button in the sidebar to remove all stored images and data from the database.\n\n---\n\n## 📄 License\n\nThis project is licensed under the MIT License. See `LICENSE` file for details.\n\n---\n\n## 🌐 Acknowledgements\n\n* [Hugging Face Diffusers](https://github.com/huggingface/diffusers)\n* [OpenAI CLIP](https://github.com/openai/CLIP)\n* [Streamlit](https://streamlit.io/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbchachar%2Fimage-generation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbchachar%2Fimage-generation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbchachar%2Fimage-generation/lists"}