I'm trying to load a set of frames from an atlas for an animation. After pack my images with TexturePacker, my atlas file is like this:
ufo_data2.png
size: 2048,2048
format: RGBA8888
filter: Nearest,Nearest
repeat: none
Ufo_gfx/red/ufo_0_red0000
rotate: false
xy: 2, 1030
size: 512, 512
orig: 512, 512
offset: 0, 0
index: -1
Ufo_gfx/red/ufo_0_red0001
rotate: false
xy: 2, 516
size: 512, 512
orig: 512, 512
offset: 0, 0
index: -1
Ufo_gfx/red/ufo_0_red0002
rotate: false
xy: 516, 1030
size: 512, 512
orig: 512, 512
offset: 0, 0
index: -1
Ufo_gfx/red/ufo_0_red0003
rotate: false
xy: 2, 2
size: 512, 512
orig: 512, 512
offset: 0, 0
index: -1
Ufo_gfx/red/ufo_0_red0004
rotate: false
xy: 516, 516
size: 512, 512
orig: 512, 512
offset: 0, 0
index: -1
Ufo_gfx/red/ufo_0_red0005
rotate: false
xy: 1030, 1030
size: 512, 512
orig: 512, 512
offset: 0, 0
index: -1
Ufo_gfx/red/ufo_0_red0006
rotate: false
xy: 516, 2
size: 512, 512
orig: 512, 512
offset: 0, 0
index: -1
I'm trying to load the animation like this:
TextureAtlas atlas;
atlas = new TextureAtlas(Gdx.files.internal("data/gfx/ufo_data.atlas"));
ufo_animation = new Animation<TextureRegion>(0.033f, atlas.findRegions("Ufo_gfx/red/"));
I found that atlas.findRegions("Ufo_gfx/red/") or even atlas.findRegions("Ufo_gfx/red/*") returns always 0 results.
I thought that using a Regex like expression will be enough to load all frames, but after look inside the findRegions() code, I found the only returns when match is exactly the string entered.
FindRegions() seems useless if one think in the way TexturePacker works.
My question is: is there a way to put an string that matches all names of images with a similar name?
Note: I found that the solution is here:
https://github.com/libgdx/libgdx/wiki/Texture-packer#image-indexes
It is needed to put images with their name and underscore and index, like a_00.png
a_01.png
Then, texture packer packs images with indexes.
The solution I found is https://github.com/libgdx/libgdx/wiki/Texture-packer#image-indexes
Need to rename files as imagename_00.png, imagename_01.png, imagename_02.png.
When images are packaging, systems understands _xx as indices and automatically puts index in atlas file.
Then you only need to call findRegions(imagename)
You can create a helper function that calls getRegion(), iterates over all regions and checks whether their name.startsWith("Ufo_gfx/red/"). Put all these in a collection and return them from your helper function.
Thats simple:
All your regions should have the same name
You should rewrite index: -1 on all regions from -1 to count number from 1
How should it look like:
ufo_data2.png
size: 2048,2048
format: RGBA8888
filter: Nearest,Nearest
repeat: none
Ufo_gfx/red/ufo_0_red
rotate: false
xy: 2, 1030
size: 512, 512
orig: 512, 512
offset: 0, 0
index: 1
Ufo_gfx/red/ufo_0_red
rotate: false
xy: 2, 516
size: 512, 512
orig: 512, 512
offset: 0, 0
index: 2
Ufo_gfx/red/ufo_0_red
rotate: false
xy: 516, 1030
size: 512, 512
orig: 512, 512
offset: 0, 0
index: 3
Ufo_gfx/red/ufo_0_red
rotate: false
xy: 2, 2
size: 512, 512
orig: 512, 512
offset: 0, 0
index: 4
Ufo_gfx/red/ufo_0_red
rotate: false
xy: 516, 516
size: 512, 512
orig: 512, 512
offset: 0, 0
index: 5
Ufo_gfx/red/ufo_0_red
rotate: false
xy: 1030, 1030
size: 512, 512
orig: 512, 512
offset: 0, 0
index: 6
Ufo_gfx/red/ufo_0_red
rotate: false
xy: 516, 2
size: 512, 512
orig: 512, 512
offset: 0, 0
index: 7
Now you can create Array just using:
atlas.findRegions("Ufo_gfx/red/ufo_0_red");
All names of regions must be:
ufo_0_red_0001
rotate: false
xy: 2, 1030
size: 512, 512
orig: 512, 512
offset: 0, 0
index: 1
ufo_0_red_0002
rotate: false
xy: 2, 516
size: 512, 512
.........
Related
I'm trying to tune the hyperparameters using the Stable-Baseline-3 Library for the network architecture.
My configuration file is:
program: main.py
method: bayes
name: sweep
metric:
goal: minimize
name: train/loss
parameters:
batch_size:
values: [16, 32, 64, 128, 256, 512, 1024]
epochs:
values: [20, 50, 100, 200, 250, 300]
lr:
max: 0.1
min: 0.000001
But if I try to add to the parameters:
policy_kwargs:
net_arch:
pi:
values: [[ 128, 128 ],[ 256, 256 ],[ 512, 512 ]]
vf:
values: [[ 128, 128 ],[ 256, 256 ],[ 512, 512 ]]
I got the following error:
wandb.errors.CommError: Invalid sweep config: invalid hyperparameter configuration: policy_kwargs
Is it possible to use wandb sweep with Stable-Baseline-3 for the network architecture?
You are trying to create a nested config. Please refer to this documentation here.
Your configuration should be:
program: main.py
method: bayes
name: sweep
metric:
goal: minimize
name: train/loss
parameters:
batch_size:
values: [16, 32, 64, 128, 256, 512, 1024]
epochs:
values: [20, 50, 100, 200, 250, 300]
lr:
max: 0.1
min: 0.000001
policy_kwargs:
parameters:
net_arch:
parameters:
pi:
values: [[ 128, 128 ],[ 256, 256 ],[ 512, 512 ]]
vf:
values: [[ 128, 128 ],[ 256, 256 ],[ 512, 512 ]]
I'm trynna make a scratch code of Semantic segmentation through U-Net. I'll use Cityscapes Dataset. I'm trying to make a dictionary(python) composed of the key(car, train, human, etc) and the value(rgb info). How can I match the dictionary with my ground_truth data?
example of labeling dictionary is like below
color_map = {
'0': [0, 0, 0], # unlabelled
'1': [128, 64, 128], # road
'2': [244, 35, 232], # sidewalk
'3': [70, 70, 70], # building
'4': [102, 102, 156], # wall
'5': [190, 153, 153], # fence
'6': [153, 153, 153], # pole
'7': [250,170, 30], # traffic_light
'8': [220, 220, 0], # traffic_sign
'9': [107, 142, 35], # vegetation
'10': [152, 251, 152], # terrain
'11': [0, 130, 180], # sky
'12': [220, 20, 60], # person
'13': [255, 0, 0], # rider
'14': [0, 0, 142], # car
'15': [0, 0, 70], # truck
'16': [0, 60, 100], # bus
'17': [0, 80, 100], # train
'18': [0, 0, 230], # motorcycle
'19': [119, 11, 32] # bicycle
}
I am working on an unsupervised image classification problem, the dataset consists of around 4700 photos of carnivores. I thought of achieving this task by constructing an autoencoder and getting the image embeddings, then applying cosine similarity. I am not getting much improvement. This is my autoencoder architecture:
Model: "functional_75"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_19 (InputLayer) [(None, 128, 128, 3)] 0
_________________________________________________________________
conv2d_126 (Conv2D) (None, 128, 128, 64) 1792
_________________________________________________________________
max_pooling2d_54 (MaxPooling (None, 64, 64, 64) 0
_________________________________________________________________
conv2d_127 (Conv2D) (None, 64, 64, 32) 18464
_________________________________________________________________
max_pooling2d_55 (MaxPooling (None, 32, 32, 32) 0
_________________________________________________________________
conv2d_128 (Conv2D) (None, 32, 32, 16) 4624
_________________________________________________________________
max_pooling2d_56 (MaxPooling (None, 16, 16, 16) 0
_________________________________________________________________
conv2d_129 (Conv2D) (None, 16, 16, 16) 2320
_________________________________________________________________
up_sampling2d_54 (UpSampling (None, 32, 32, 16) 0
_________________________________________________________________
conv2d_130 (Conv2D) (None, 32, 32, 32) 4640
_________________________________________________________________
up_sampling2d_55 (UpSampling (None, 64, 64, 32) 0
_________________________________________________________________
conv2d_131 (Conv2D) (None, 64, 64, 64) 18496
_________________________________________________________________
conv2d_132 (Conv2D) (None, 64, 64, 3) 1731
_________________________________________________________________
up_sampling2d_56 (UpSampling (None, 128, 128, 3) 0
=================================================================
Total params: 52,067
Trainable params: 52,067
Non-trainable params: 0
_________________________________________________________________
Please suggest some tips for improvement.
caffe'doc says that:
layer {
name: "upsample", type: "Deconvolution"
bottom: "{{bottom_name}}" top: "{{top_name}}"
convolution_param {
kernel_size: {{2 * factor - factor % 2}} stride: {{factor}}
num_output: {{C}} group: {{C}}
pad: {{ceil((factor - 1) / 2.)}}
weight_filler: { type: "bilinear" } bias_term: false
}
param { lr_mult: 0 decay_mult: 0 }
}
I have no idea why to set kenrel_size, stride, and pad like this?
for upsampling, if you want resize factor to be 2, then the parameter would be kernel_size: 4, stride:2, pad:1
I added "font.size": 15.0 to the tab_label class in Default.sublime-theme.
{
"class": "tab_label",
"fg": [0, 0, 0, 255],
"shadow_color": [255, 255, 255, 80],
"shadow_offset": [0, 1],
"font.size": 15.0
}
The font size did change, but the lower parts of the file names somehow 'get cut'.
What should I do?