|
|
||
|---|---|---|
| .. | ||
| docs | ||
| utils | ||
| README.md | ||
| app.py | ||
| flow.py | ||
| nodes.py | ||
| requirements.txt | ||
README.md
PocketFlow Streamlit Image Generation HITL
Human-in-the-Loop (HITL) image generation application using PocketFlow and Streamlit. Enter text prompts, generate images with OpenAI, and approve/regenerate results.
Features
- Image Generation: Uses OpenAI's
gpt-image-1model to generate images from text prompts - Human Review: Interactive interface to approve or regenerate images
- State Machine: Clean state-based workflow (
initial_input→user_feedback→final) - PocketFlow Integration: Uses PocketFlow
NodeandFlowfor image generation with built-in retries - Session State Management: Streamlit session state acts as PocketFlow's shared store
- In-Memory Images: Images stored as base64 strings, no disk storage required
How to Run
-
Set OpenAI API Key:
export OPENAI_API_KEY="your-openai-api-key" -
Install Dependencies:
pip install -r requirements.txt -
Run the Streamlit Application:
streamlit run app.py -
Access the Web UI: Open the URL provided by Streamlit (usually
http://localhost:8501).
Usage
- Enter Prompt: Describe the image you want to generate
- Generate: Click "Generate Image" to create the image
- Review: View the generated image and choose:
- Approve: Accept the image and move to final result
- Regenerate: Generate a new image with the same prompt
- Final: View approved image and optionally start over
Files
app.py: Main Streamlit application with state-based UInodes.py: PocketFlowGenerateImageNodedefinitionflow.py: PocketFlowFlowfor image generationutils/generate_image.py: OpenAI image generation utilityrequirements.txt: Project dependenciesdocs/design.md: System design documentationREADME.md: This file