56 lines
1.4 KiB
Plaintext
Executable File
56 lines
1.4 KiB
Plaintext
Executable File
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "16d67fa4",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import torch\n",
|
|
"from diffusers import FluxPipeline\n",
|
|
"from huggingface_hub import login as hf_login\n",
|
|
"\n",
|
|
"print(\"Setup ...\")\n",
|
|
"hf_login(token=\"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\")\n",
|
|
"pipe = FluxPipeline.from_pretrained(\"black-forest-labs/FLUX.1-dev\", torch_dtype=torch.bfloat16)\n",
|
|
"pipe.enable_model_cpu_offload() #save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power\n",
|
|
"\n",
|
|
"prompt = \"A cat holding a sign that says hello world\"\n",
|
|
"print(\"Generating image ...\")\n",
|
|
"image = pipe(\n",
|
|
" prompt,\n",
|
|
" height=1024,\n",
|
|
" width=1024,\n",
|
|
" guidance_scale=3.5,\n",
|
|
" num_inference_steps=50,\n",
|
|
" max_sequence_length=512,\n",
|
|
" generator=torch.Generator(\"cpu\").manual_seed(0)\n",
|
|
").images[0]\n",
|
|
"image.save(\"flux-dev.png\")"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.11.2"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|