-
Notifications
You must be signed in to change notification settings - Fork 417
Expand file tree
/
Copy pathgenerate.py
More file actions
executable file
·29 lines (26 loc) · 1.07 KB
/
generate.py
File metadata and controls
executable file
·29 lines (26 loc) · 1.07 KB
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
# Copyright © 2022 BAAI. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License")
import torch
from flagai.auto_model.auto_loader import AutoLoader
from flagai.model.predictor.predictor import Predictor
# Initialize
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
loader = AutoLoader(task_name="text2img", #contrastive learning
model_name="AltDiffusion-m18",
model_dir="./checkpoints",
fp16=False)
model = loader.get_model()
model.eval()
model.to(device)
predictor = Predictor(model)
prompt = "สาวสวย"
# negative_prompt = "nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, extra head, extra legs,fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry"
seed = 553124
result = predictor.predict_generate_images(
prompt=prompt,
# negative_prompt=negative_prompt,
outpath="./AltDiffusionOutputs",
ddim_steps=50,
seed=seed)
print(type(result), result)