A web application that allows influencers to let their fans generate AI selfies with them. Fans can upload a photo or fetch their profile picture from social media, pay via promo code or payment, and receive an AI-generated selfie with the influencer.
- Fan-facing page: Fans can enter their social media handle or upload a photo, pay via promo code/Stripe/Lightning, and generate a selfie
- Admin panel: Influencers can configure branding, pricing, upload reference images, and manage promo codes
- Social media integration: Fetch profile pictures from Twitter/X, Bluesky, GitHub, Mastodon, and Nostr
- Payment options: Promo codes, Stripe, and Bitcoin Lightning (via LNbits)
- ComfyUI backend: Image generation is handled by a ComfyUI server
- Presets: Configure multiple generation presets with different influencer images, dimensions, prompts, and pricing
This application requires a ComfyUI server for image generation. You must use the ValyrianTech ComfyUI template, which includes an nginx server for serving output images.
Docker images:
valyriantech/comfyui-with-flux:latest- Includes FLUX.1 models pre-installedvalyriantech/comfyui-without-flux:latest- Without FLUX models
Note: The template comes with FLUX.1 pre-installed, but GenSelfie requires FLUX.2. You will need to download the FLUX.2 models after deployment.
Note: FLUX.2 requires an RTX PRO 6000 GPU or equivalent.
Deploy on RunPod:
-
Get Hugging Face access:
- Create a Hugging Face account if you don't have one
- Go to FLUX.2-dev and request access to the gated repository
- Create an access token at Hugging Face Settings
-
Deploy the ComfyUI pod:
- Click this link to deploy: Deploy ComfyUI on RunPod
- Select an RTX PRO 6000 GPU (or equivalent with sufficient VRAM)
- Set your Hugging Face token in the pod's environment variables as
HF_TOKEN
-
Download the models:
- Once the pod is running, open a terminal in the pod
- Run:
bash /download_Flux2.sh - Wait for the models to download (this may take a while)
-
Get the ComfyUI URL:
- In the RunPod dashboard, find the Direct TCP Port Mappings section (not the proxy URL)
- Copy the IP and port (e.g.,
http://123.45.67.89:12345) - You'll need this for the
COMFYUI_URLenvironment variable
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment:
cp .env.example .env # Edit .env with your settings -
Run the app:
python main.py
With verbose logging:
python main.py --verbose
All CLI options:
python main.py --help # Options: # -v, --verbose Enable verbose logging # --host HOST Host to bind to (default: 0.0.0.0) # --port PORT Port to bind to (default: 8000) # --reload Enable auto-reload for development
-
Access the app:
- Fan page: http://localhost:8000
- Admin panel: http://localhost:8000/admin
-
First-time setup:
- On first run, an admin password will be auto-generated and saved to
.env - Check the console output or
.envfile for the password - Log in to the admin panel and configure your settings
- On first run, an admin password will be auto-generated and saved to
| Variable | Description | Required |
|---|---|---|
ADMIN_PASSWORD |
Admin panel password | Auto-generated |
COMFYUI_URL |
ComfyUI server URL | Yes |
STRIPE_SECRET_KEY |
Stripe secret key | For Stripe payments |
STRIPE_PUBLISHABLE_KEY |
Stripe publishable key | For Stripe payments |
PUBLIC_URL |
Public URL for Stripe redirects | For Stripe on RunPod |
LNBITS_URL |
LNbits instance URL | For Lightning payments |
LNBITS_API_KEY |
LNbits API key | For Lightning payments |
DEBUG |
Enable debug mode | No (default: false) |
VERBOSE |
Enable verbose logging | No (default: false) |
DATA_DIR |
Directory for database and uploads | No (default: /workspace) |
The default DATA_DIR=/workspace works automatically with RunPod network volumes. For local development, set DATA_DIR=./data or another local path.
When running on RunPod with Stripe payments, you must set the PUBLIC_URL environment variable to your RunPod proxy URL. This is required because Stripe redirects users back to your app after payment, and it needs the public-facing URL (not the internal IP).
- In the RunPod dashboard, find your pod's Proxy URL (e.g.,
https://abc123-8000.proxy.runpod.net) - Set this as the
PUBLIC_URLenvironment variable or configure it in the admin panel under Stripe Settings
Without this, Stripe redirects will fail because they'll use the internal container URL which isn't accessible from the internet.
GenSelfie/
├── main.py # FastAPI entry point
├── config.py # Settings & environment
├── database.py # SQLite models
├── routers/
│ ├── admin.py # Admin panel routes
│ └── public.py # Fan-facing routes
├── services/
│ ├── comfyui.py # ComfyUI API client
│ ├── social.py # Social media profile fetching
│ ├── payments.py # Stripe & LNbits integration
│ └── codes.py # Promo code validation
├── templates/ # Jinja2 templates
├── static/ # CSS, JS, uploads
├── workflows/ # ComfyUI workflow JSON files
├── input_examples/ # Example input images
└── genselfie.db # SQLite database (created on first run)
The easiest way to deploy GenSelfie is on RunPod:
- Deploy GenSelfie: Deploy GenSelfie on RunPod
- Select a CPU pod (no GPU needed for the web app itself)
- Access the admin panel at your pod's proxy URL +
/admin
See the ComfyUI Server section above for setting up the required ComfyUI backend.
⚠️ Important: If both GenSelfie and ComfyUI are running in the same RunPod datacenter, the connection may fail due to internal DNS issues. Deploy them in different datacenters to avoid this problem.
The GenSelfie Docker image is available on Docker Hub:
docker pull valyriantech/genselfie:latestDocker image: valyriantech/genselfie:latest
docker run -p 8000:8000 \
-e ADMIN_PASSWORD=your_password \
-e COMFYUI_URL=http://your-comfyui-server:8080 \
-v ./data:/workspace \
valyriantech/genselfie:latestEnvironment variables can be passed with -e flags. See the Environment Variables section for all available options.
Persistent storage: Mount a volume to /workspace to persist the database and uploaded files. On RunPod, the /workspace directory is automatically mounted to the network volume.
To build the Docker image yourself:
# Build the image
docker build -t genselfie .
# Run locally
docker run -p 8000:8000 \
-e ADMIN_PASSWORD=your_password \
-e COMFYUI_URL=http://your-comfyui-server:8080 \
-v ./data:/workspace \
genselfieA helper script is provided to build and push to Docker Hub:
# Build and push with today's date tag
python build_docker.py genselfie
# Build and push with custom tag
python build_docker.py genselfie --tag v1.0.0
# Also tag and push as :latest
python build_docker.py genselfie --latest
# Use a different Docker Hub username
python build_docker.py genselfie --username myusername --latestThe Dockerfile uses a multi-stage build:
- Builder stage: Installs dependencies in a virtual environment
- Production stage: Copies only the necessary files and virtual environment
The image:
- Based on
python:3.12 - Exposes port
8000 - Uses
/workspaceas the default data directory (RunPod compatible) - Runs via
start.shwhich starts the FastAPI server
- Twitter/X: Uses unavatar.io service
- Bluesky: Uses AT Protocol public API
- GitHub: Direct avatar URL
- Mastodon: Uses instance API with WebFinger
- Nostr: Uses nostrhttp.com API (supports npub, hex pubkey, and NIP-05 identifiers)
MIT
