File size: 3,728 Bytes
138a725
 
 
 
 
f0dfa9e
83544ca
 
940bc46
 
 
 
 
 
 
 
 
b28a5fd
0ce25f9
940bc46
 
0ce25f9
940bc46
 
0ce25f9
940bc46
 
 
 
 
 
 
 
 
 
 
 
 
 
b28a5fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
940bc46
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
library_name: diffusers
tags:
- text-to-image
- stable-diffusion
base_model: stabilityai/stable-diffusion-xl-base-1.0
license: apache-2.0
pipeline_tag: text-to-image
---
# DreamBooth LoRA Training with Stable Diffusion XL on Trump Thumbs Up Images

This repository contains instructions and code for training a DreamBooth LoRA model using Stable Diffusion XL on a dataset of images featuring Donald Trump giving a thumbs up gesture. The trained model can be used to generate high-quality images of Trump showing thumbs up in various contexts.

## Sample Images

Here are a few sample images generated by the trained model:

![Trump Thumbs Up in India](Output-Complex/Trump1.jpeg)
* 1. A high quality picture of Trump showing thumbs up in a busy street of India, detailed, sharp focus.

![Trump Thumbs Up in a Taco Restaurant](Output-Complex/Trump7.jpeg)
* 2. An intricately detailed digital painting of Donald Trump giving a thumbs up at a taco restaurant. The background includes colorful decor and a bustling atmosphere with people enjoying their meals.

![Trump Thumbs Up at the Beach](Output-Complex/Trump2.jpeg)
* 3. A high-quality photo of Donald Trump giving a thumbs up on a sunny beach. The scene includes clear blue water, white sand, and Trump in casual beachwear. The image is detailed, with Trump’s smiling face and the vibrant beach setting in sharp focus.

## Requirements

The script requires Python 3.9 and several Python packages including PyTorch, Hugging Face Transformers, Diffusers, and Accelerate. Additional dependencies are listed in the `requirements_sdxl.txt` file.

## Installation

To get started, clone the repository and navigate to the project directory. Install the required packages using pip and the provided `requirements_sdxl.txt` file. Log in to the Hugging Face Hub using the `huggingface-cli login` command.

## Usage

To train the model, prepare a dataset of images featuring Donald Trump giving a thumbs up gesture and place them in a directory. Run the training script `train_dreambooth_lora_sdxl.py` with the appropriate command-line arguments specifying the pretrained model, instance data directory, output directory, and various training hyperparameters.

After training, load the trained LoRA weights and use the `DiffusionPipeline` class from the Diffusers library to generate images. Provide a prompt describing the desired image, such as "A high quality picture of Trump showing the thumbs up in Paris detailed, sharp focus". The generated image will be saved to the specified output directory.
## API Server

[SDXL_API_Server](https://huggingface.co/Paresh1879/stable-diffusion-xl-thumbsup-extend/blob/main/SDXL_API_Server.py) contains the server side code containing the below information : 

- **Image Generation Endpoint:** 
  - `/generate_image`: Accepts POST requests with prompts to generate Trump thumbs up images.
  - Users provide prompts describing desired image contexts.
  - Images are generated using a pre-trained model.

- **API Key Authentication:** 
  - Ensures presence of API key for authorization.
  - Rejects unauthorized requests.

- **API Key Usage Tracking:** 
  - Tracks API key usage count.
  - `/api_key_usage` endpoint retrieves usage count.
    
- **The Generated Output in postman:**
  - ![POST Output](postman_output.png)
  - *Endpoint to get generated images via a prompt using the above trigger keyword and style*
  - ![Api_Key_Counts](api_key_counts.png)
  - *Server maintains a count of each time the API key was used to successfully generate an image.*


## Results

The generated images will be saved in the specified output directory, showcasing Trump giving a thumbs up gesture in different contexts based on the provided prompts.