-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.py
56 lines (50 loc) · 2.24 KB
/
config.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright 2024 Nikolai Körber. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
class ConfigPerco:
# TFDS config
# data_dir = "/tf/notebooks/tensorflow_datasets/"
data_dir = "/tf/notebooks/OpenImagesV6"
image_list_file = "/tf/notebooks/OpenImagesV6/list_train_files.txt"
# global path (adjust to your needs)
global_path = "/tf/notebooks/PerCo/src"
# BLIP 2 config ({Salesforce/blip2-opt-2.7b, Salesforce/blip2-opt-2.7b-coco, Salesforce/blip2-opt-6.7b, Salesforce/blip2-opt-6.7b-coco})
# Overview of compatible models: https://huggingface.co/Salesforce
blip_model = "Salesforce/blip2-opt-2.7b-coco"
max_number_tokens = 32
# PerCo
target_rate = 0.1250
# see Table 2 in https://arxiv.org/abs/2309.15505 for more information
# key: target bit-rate
# value: tuple (x, y), where x and y correspond to the spatial and codebook size, respectively.
rate_cfg = {}
rate_cfg[0.1250] = (64, 256)
rate_cfg[0.0937] = (64, 64)
rate_cfg[0.0507] = (32, 8196)
rate_cfg[0.0313] = (32, 256)
rate_cfg[0.0098] = (16, 1024)
rate_cfg[0.0024] = (8, 1024)
rate_cfg[0.0019] = (8, 256)
# {v_prediction, epsilon}
prediction_type = "v_prediction"
# LPIPS loss scalar (if --use_lpips is set)
lpips_weight = 0.1
# classifier-free guidance scale
guidance_scale = 3.0
# probability of dropping text-conditioning
cond_drop_prob = 0.1
# number of sampling steps
num_inference_steps = 20 # 20 for < 0.05bpp
# see https://colab.research.google.com/github/pcuenca/diffusers-examples/blob/main/notebooks/stable-diffusion-seeds.ipynb#scrollTo=9af32168
random_seed = 3868512668962463