Update README.md
Browse files
README.md
CHANGED
|
@@ -27,38 +27,11 @@ You should use `tugce` to trigger the image generation.
|
|
| 27 |
## Use it with the [🧨 diffusers library](https://github.com/huggingface/diffusers)
|
| 28 |
|
| 29 |
```py
|
| 30 |
-
from fastapi import FastAPI, HTTPException
|
| 31 |
-
from fastapi.responses import FileResponse
|
| 32 |
-
import torch
|
| 33 |
from diffusers import AutoPipelineForText2Image
|
| 34 |
-
import
|
| 35 |
-
|
| 36 |
-
app = FastAPI()
|
| 37 |
-
|
| 38 |
-
# Model ve LoRA'yı yükle
|
| 39 |
pipeline = AutoPipelineForText2Image.from_pretrained('black-forest-labs/FLUX.1-dev', torch_dtype=torch.float16).to('cuda')
|
| 40 |
pipeline.load_lora_weights('codermert/tugce2-lora', weight_name='flux_train_replicate.safetensors')
|
| 41 |
-
|
| 42 |
-
@app.post("/generate_image")
|
| 43 |
-
async def generate_image(prompt: str, width: int, height: int):
|
| 44 |
-
try:
|
| 45 |
-
image = pipeline(
|
| 46 |
-
prompt,
|
| 47 |
-
width=width,
|
| 48 |
-
height=height
|
| 49 |
-
).images[0]
|
| 50 |
-
|
| 51 |
-
img_byte_arr = io.BytesIO()
|
| 52 |
-
image.save(img_byte_arr, format='PNG')
|
| 53 |
-
img_byte_arr.seek(0)
|
| 54 |
-
|
| 55 |
-
return FileResponse(img_byte_arr, media_type="image/png")
|
| 56 |
-
except Exception as e:
|
| 57 |
-
raise HTTPException(status_code=500, detail=str(e))
|
| 58 |
-
|
| 59 |
-
if __name__ == "__main__":
|
| 60 |
-
import uvicorn
|
| 61 |
-
uvicorn.run(app, host="0.0.0.0", port=8000)
|
| 62 |
```
|
| 63 |
|
| 64 |
For more details, including weighting, merging and fusing LoRAs, check the [documentation on loading LoRAs in diffusers](https://huggingface.co/docs/diffusers/main/en/using-diffusers/loading_adapters)
|
|
|
|
| 27 |
## Use it with the [🧨 diffusers library](https://github.com/huggingface/diffusers)
|
| 28 |
|
| 29 |
```py
|
|
|
|
|
|
|
|
|
|
| 30 |
from diffusers import AutoPipelineForText2Image
|
| 31 |
+
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
pipeline = AutoPipelineForText2Image.from_pretrained('black-forest-labs/FLUX.1-dev', torch_dtype=torch.float16).to('cuda')
|
| 33 |
pipeline.load_lora_weights('codermert/tugce2-lora', weight_name='flux_train_replicate.safetensors')
|
| 34 |
+
image = pipeline('your prompt').images[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
```
|
| 36 |
|
| 37 |
For more details, including weighting, merging and fusing LoRAs, check the [documentation on loading LoRAs in diffusers](https://huggingface.co/docs/diffusers/main/en/using-diffusers/loading_adapters)
|