Views
No views yet
1from inference_solver import FlexARInferenceSolver
2from PIL import Image
3import os
4import torch
5import random
6os.environ["CUDA_VISIBLE_DEVICES"] = "0"
7
8def set_seed(seed):
9 random.seed(seed)
10 np.random.seed(seed)
11 torch.manual_seed(seed)
12 torch.cuda.manual_seed(seed)
13 torch.cuda.manual_seed_all(seed)
14 torch.backends.cudnn.deterministic = True
15 torch.backends.cudnn.benchmark = False
16
17inference_solver = FlexARInferenceSolver(
18 model_path = "UVT_7B_448", #path to your model
19 precision="fp16", #bf16
20 target_size=448, #fixed 448
21)
22
23max_out = 1
24for i in range(max_out):
25 set_seed(i)
26
27 qas = [["Acknowledge the spatial structure and identify variations in light intensity, translating these into a gradient scale representing distances. Accentuate regions where light diminishes gradually, enhancing the perception of depth by dimming peripheral areas. Adjust the distribution of luminance to highlight the central vanishing point, converting detailed textures into smooth transitions of grayscale." + " <|image|>", None]]
28 images = [Image.open("./demo_input/rain_1.jpg")]
29
30 generated = inference_solver.generate(
31 images=images,
32 qas=qas,
33 max_gen_len=4096,
34 temperature=1.0,
35 logits_processor=inference_solver.create_logits_processor(cfg=1., image_top_k=2048),
36 )
37 new_image = generated[1][0]
38 new_image.save(f'./test_output_{i}.png', format='PNG')