├── dragon.png
├── terrarium.png
├── fluxSchenll.ico
├── fluxSchenll.png
├── Flux1-Schnell2.gif
├── interior-1step.png
├── red-whiteTREE.png
├── requirements.txt
├── interior-2steps.png
├── interior-3steps.png
├── interior-4steps.png
├── GenerateImages.py
└── README.md
/dragon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabiomatricardi/FLUX1-Schenll_TAI-freeAPI/main/dragon.png
--------------------------------------------------------------------------------
/terrarium.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabiomatricardi/FLUX1-Schenll_TAI-freeAPI/main/terrarium.png
--------------------------------------------------------------------------------
/fluxSchenll.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabiomatricardi/FLUX1-Schenll_TAI-freeAPI/main/fluxSchenll.ico
--------------------------------------------------------------------------------
/fluxSchenll.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabiomatricardi/FLUX1-Schenll_TAI-freeAPI/main/fluxSchenll.png
--------------------------------------------------------------------------------
/Flux1-Schnell2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabiomatricardi/FLUX1-Schenll_TAI-freeAPI/main/Flux1-Schnell2.gif
--------------------------------------------------------------------------------
/interior-1step.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabiomatricardi/FLUX1-Schenll_TAI-freeAPI/main/interior-1step.png
--------------------------------------------------------------------------------
/red-whiteTREE.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabiomatricardi/FLUX1-Schenll_TAI-freeAPI/main/red-whiteTREE.png
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabiomatricardi/FLUX1-Schenll_TAI-freeAPI/main/requirements.txt
--------------------------------------------------------------------------------
/interior-2steps.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabiomatricardi/FLUX1-Schenll_TAI-freeAPI/main/interior-2steps.png
--------------------------------------------------------------------------------
/interior-3steps.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabiomatricardi/FLUX1-Schenll_TAI-freeAPI/main/interior-3steps.png
--------------------------------------------------------------------------------
/interior-4steps.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fabiomatricardi/FLUX1-Schenll_TAI-freeAPI/main/interior-4steps.png
--------------------------------------------------------------------------------
/GenerateImages.py:
--------------------------------------------------------------------------------
1 | from together import Together
2 | import requests
3 | from PIL import Image
4 | from io import BytesIO
5 | APIK = input('Your Tegether API Key: ')
6 | prompt = input('/imagine: ')
7 | client = Together(api_key=APIK)
8 | try:
9 | response = client.images.generate(prompt=prompt,
10 | model="black-forest-labs/FLUX.1-schnell-Free",
11 | steps=4,
12 | width=1024,
13 | height=768,
14 | n=1)
15 | imurl = response.data[0].url
16 | my_res = requests.get(imurl)
17 | my_img = Image.open(BytesIO(my_res.content))
18 | my_img.show()
19 | savename = input('Give me a name (end with .png please): ')
20 | my_img.save(savename)
21 | except:
22 | print('Check you API Key is a valid one at https://api.together.ai/settings/api-keys !')
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # FLUX1-Schenll_TAI-freeAPI
2 | How to generate Images with Flux.1-Schnell and free API from Tegether.AI
3 |
4 |
5 |
6 | Together AI provide free access with API to Top Notch models.
7 |
8 | ## Flux.1-Schenll is awesome at very small Steps (even only 1 or 4)
9 |
10 | Flux.1-Schenll can be used for free (siwth some limitations)
11 | - remotely with an API Key
12 | - on the web with https://api.together.ai/
13 |
14 | Free quota:
15 | - 60 Requests Per Minute
16 | - Total 60.000 requests per Months
17 |
18 | Register at https://api.together.ai/
19 |
20 |
21 | ### What is Flux.1-Schnell
22 | FLUX.1-Schnell is a 12 billion parameter rectified flow transformer designed to generate high-quality images from text descriptions. It is trained using latent adversarial diffusion distillation, which allows it to produce images in just 1 to 4 steps. This model is optimized for speed and efficiency, making it suitable for both personal and commercial use.
23 |
24 | It is available under an Apache 2.0 license, and its implementation and sampling code can be found in a dedicated GitHub repository. FLUX.1-Schnell can be used to create a variety of images, including photorealistic scenes, artistic illustrations, and concept art, applicable to diverse applications.
25 |
26 | FLUX.1-Schnell can produce images in only 4 steps due to its training methodology and architecture. Here are the key factors that enable this efficiency:
27 |
28 | - Latent Adversarial Diffusion Distillation: This training technique allows the model to generate high-quality images with fewer steps compared to traditional diffusion models. It distills the knowledge from a larger, more complex model into a smaller, more efficient one, enabling faster inference.
29 | - Rectified Flow Transformer Architecture: The model's architecture is designed to optimize the flow of information during the generation process. This includes a hybrid architecture that combines multimodal and parallel diffusion transformer blocks, enhancing both speed and quality.
30 | - Optimized Inference: The model includes optimizations such as compiled fp8 quantization and optimized attention kernels, which further accelerate the image generation process. These optimizations are crucial for achieving high-quality outputs in fewer steps.
31 |
32 | #### Note
33 | > You cannot set more than 4 steps in the generation!
34 |
35 | ## Generation quality by number of steps
36 |
37 | > PROMPT: Depict a cozy, warmly lit bookstore cafe on a rainy evening. The atmosphere should be inviting and nostalgic, with soft yellow lighting from vintage lamps illuminating rows of well-worn books. Show patrons reading in comfortable armchairs, steam rising from their coffee cups. The large front window should reveal a glistening wet street outside, with blurred lights from passing cars. Emphasize the contrast between the warm interior and the cool, rainy exterior.
38 |
39 |
40 | Here the same prompt from 1 to 2 steps (left to right)
41 |
42 |
43 |
44 | Here the same prompt from 3 to 4 steps (left to right)
45 |
46 |
47 |
48 |
49 |
50 |
51 | ---
52 |
53 | Remote calls requires the Together package. Recommended to use Python 3.12 to avoid dependency clashes
54 | ```
55 | pip install together==1.4.1
56 | ```
57 |
58 | Or Clone the repo and create a venv and install from requirements
59 | ```
60 | python312 -m venv venv
61 | venv\Scripts\activate
62 | pip install -r requirements.txt
63 | ```
64 |
65 | To run the generation:
66 | ```
67 | Python .\GenerateImages.py
68 | ```
69 | You will be asked for:
70 | - a valid API key
71 | - a prompt
72 | - a filename, once the miage is genrated
73 |
74 |
75 | ### Some prompt examples
76 | You can find more [here](https://getimg.ai/blog/flux-1-prompt-guide-pro-tips-and-common-mistakes-to-avoid) and [here](https://aimlapi.com/blog/master-the-art-of-ai-top-10-prompts-for-flux-1-by-black-forests-labs)
77 |
78 |
79 | > A hanging glass terrarium featuring a miniature rainforest scene with colorful orchids and tiny waterfalls. Just beyond the glass, a neon sign reads 'Rainforest Retreat.' The rain-soaked glass creates a beautiful distortion, adding a soft glow to the sign's vibrant colors
80 |
81 |
82 |
83 |
84 | ---
85 |
86 |
87 | > Photo realistic scene inspired by LOTR: [A tiny red dragon sleeps curled up in a nest on a medieval wizard's table]. Shot with a macro lens (f/2.8, 50mm) and a Canon EOSR5, the soft focus captures [the cozy morning light filtering through a near by window]. The pastel colors and whimsical steam shapes enhance the serene atmosphere, evoking a DnD RPG setting. The image is rendered in 16K and 8K, highlighting [the intricate details and medieval charm].
88 |
89 |
90 |
91 | ---
92 |
93 |
94 | > A single tree standing in the middle of the image. The left half of the tree has bright, vibrant red leaves under a bright, sunny blue sky, while the right half has bare branches covered in frost, with a cold, dark, thunderous sky. On the left there's orange, lush grass on the ground; on the right - thick snow. The split is sharp, with the transition happening right down the middle of the tree
95 |
96 |
97 |
98 |
99 | ---
100 |
101 | ## Resources
102 | - Together AI [pypi package page](https://pypi.org/project/together/)
103 | - [Together.AI](https://api.together.ai/)
104 | - [Introduction](https://docs.together.ai/docs/introduction) to TogetherAI and services
105 | - [Together.Cookbooks](https://github.com/togethercomputer/together-cookbook)
106 | - How to create Images - [QuickStart](https://docs.together.ai/docs/images-overview)
107 |
108 |
109 | ---
110 |
111 | Gradio Interface soon
112 |
113 | ---
114 |
115 |
116 |
117 |
118 |
119 |
120 |
--------------------------------------------------------------------------------