2020年3月13日星期五

Effect of operating frequency on system power, penetration ability, equipment volume, and system performance

Note:
This article considers empirical situations and may not apply to all situations.

1. Effect of frequency on power

Generally speaking, the higher the frequency, the smaller the power.
The power affects the working distance. Therefore, the system with a higher frequency often has a smaller working distance. The phenomenon that millimeter waves are commonly used in vehicles, 5G small cells, etc. can be explained with this.


2. Frequency vs. Penetration Capability

Generally, the lower the frequency, the stronger the penetration. (The penetrating ability here refers to the penetrating ability of the detection, that is, the diffractive ability. It does not refer to the energy penetration of gamma rays, lasers, etc.)

3. Relationship between frequency and device volume

Generally, when the other conditions are the same, the larger the operating frequency, the smaller the equipment size. This can be understood from the perspective of receiving and transmitting antennas. For example, millimeter waves can be chip-sized.

4. Relationship between frequency and system performance

When selecting a frequency, the cost is usually known, and the available frequency is determined based on the nature of the budget and frequency. For example, when the budget cost is low, a more mature frequency band should be selected.

Image aliasing (Moire pattern)

Image sampling and quantization are necessary steps in digital image acquisition and storage.

According to Nyquist's sampling law:

An analog signal can be perfectly reconstructed form its samples as long as the sampling frequency is at least twice the amount of the maximum frequency component present in the analog signal.

That is, the sampling frequency is at least twice the highest frequency in the analog signal. Otherwise, aliasing will occur.


Python regular expressions match specific input and output images

The saved results of an image generation experiment are the following pictures. Now I want to calculate the SSIM and PSNR between * _real_image * and * _synthesized * in the same iterations.


Calculate picture SSIM and PSNR using Python

This article mainly shows the calculation of two pictures psnr and ssim using Python.


Some reasons for error "Segmentation fault (core dumped)"

Sometimes we encounter "Segmentation fault (core dumped)", meaning that memory is used incorrectly, which may be caused by the following reasons.

1. Caused by breakpoints in the program

It may be caused by breakpoints in the program for debugging, such as pdb.set_trace (), etc.

In most cases, the pdb debugging tool that comes with Python will not cause problems, but individual cases do occur. The specific reason is not clear, but you can just remove pdb.set_trace () to solve it.

2. Mismatch between number of objects and number of categories

This is easy to appear in the debugging process of specific segmentation detection tasks such as yolo. You can change the number of filter files, or the number of categories to solve. The specific solution should be determined according to the specific situation.



2020年2月27日星期四

A method for viewing image reconstruction results when connecting to a server remotely

When connecting to the server remotely, the internet speed may be slow. There are too many images saved in the experiment to open the folder.

One solution is as follows:

1. Use the command line to enter the folder where the images are saved;
2. Use the tar compression command to select some pictures (such as the latest epoch picture);
3. Compress them and transfer them to your local computer.

The above process can be simplified to the following command:

(base) user@xxx:~/xxx$ tar cvf temResult.tar ./web/images/epoch080_iter159*

Parse conf error: proxy [RDP] local_port error

This is an error that may occur when configuring frp files. The reason for this error may be that the configuration file (such as the ini file under windows) has a format error. E.g:

The comments in the .ini file are not #, nor%.



solve:

Just delete the comment or use the correct comment method.

Edit text on the command line using vim under Ubuntu

When you cannot mount remotely, you can use vim to edit simple text files.

Frequently used commands:

1. Use the arrow keys to move the cursor to the position you want to edit;

2. Press i to enter insert mode;

3. After editing, press esc to exit insert mode;

4. Use: wq to save and exit.



More detailed commands can refer to:

https://blog.csdn.net/weixin_37657720/article/details/80645991

How to keep programs running after ssh interruption?

After verification, at least the following two methods can be used:

method 1:

Use the nohup command. Suitable for a single, simple interactive command.

https://www.cnblogs.com/jinxiao-pu/p/9131057.html

Method 2:

Use the screen command. Suitable for complex interactive commands.

https://blog.csdn.net/qq_28832135/article/details/79831700

Solution for notability software cannot play recordings

Notability suddenly appeared unable to play the recording. Notes that were previously playable are now unplayable.



Solution:

Simply turn Notability off and back on (it is not necessary to restart the device)



Successfully resolved.

Remote access to lab / office server using frp

The server's external network access has been unstable, so I wanted to buy a cheap server + frp tool on Alibaba Cloud to achieve remote server external network access.


Step 1: The basic steps, that is, to achieve remote access to the intranet Windows computer by FRP, see:

https://www.computationalimaging.cn/2020/02/remote-access-to-office-school-windows.html


Step2: After completing step 1, you only need to install frpc on the server, and the configuration file is written as(assuming that you plan to access by ssh):


[common]
server_addr = 47.XXX.XX.XX
server_port = 7001
token=XXXXXX
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6060

Then execute ./frpc -c ./frpc.ini to run

Step 3: Remote access


ssh -p 6060 username@47.XXX.XX.XX

You can also complete file mounting through file mounting software such as winshffs / xshell. You only need to change the port from 22 to 6060.

Remote access to office / school windows computer using frp

When we want to access the computer at school or office at home, we can achieve it by the following steps:


2020年1月14日星期二

Method to get all attributes of a Python object

In order to get all the attributes of a Python object, we only need to do the following:

dir(obj)

1only batches of spatial targets supported (non-empty 3D tensors) but got targets of size: :

I encountered the above problem when using Pytorch's CrossEntropy function.

E.g:
criterion = nn.CrossEntropyLoss()

loss = criterion(logit, target.long())
If logit.shape is torch.Size ([4, 31, 256, 256])  and target.shape is [4, 256, 256, 1], where 4 is the batchSize and 31 is the number of categories.

The error 1only batches of spatial targets supported (non-empty 3D tensors) but got targets of size:: will appear.

2020年1月5日星期日

FIFO over run error TCSPC (Pico Harp 300)

FIFO over run error in time-dependent single photon counter (model PicoHarp300) in continuous measurement mode

Reason: There are relevant instructions in the manual. In summary, there are too many photons and it is impossible to record in real time;

Solution: Turn down the laser power to reduce the number of photons per unit time.

Installation of scanning galvanometer GAS012 and GVS012

Step1: Remove the three hex screws on the side of GVS012

Step2: Align the three holes on the side of GAS012 with the three holes on the side of GVS012;

Step3: Screw the three hexagonal screws back on.

Step4: You can use the M4 / M6 screws to fix GAS012 to the optical tablet.

Image .save FileNotFoundError: [Errno 2] No such file or directory: '../Dataset/testResults/5.png'

Because it is .save, the reason is obviously not that there is no "../Dataset/testResults/5.png" file.

It is:

No ../Dataset/testResults/ directory

Example:


  1. This directory has not been created
  2. typo in the directory
  3. use Chinese or other characters.



After confirming that the directory is correct, the error is resolved.

ssh upload file to server

When there is a problem with the winsshfs mount file, you can directly use ssh to upload it, as follows:

scp ./1229.zip username@servername:~/

Python: divide a folder into small folders

Assume that there are 10,000 pictures in a large folder. This code is used to divide the 10,000 pictures into 9 subfolders according to the characteristics of the file name:

dir_sum   
    --dir1
    --dir2
    ...
    --dir9

RuntimeError: Given groups=1, weight of size [64, 3, , ], expected input[1, 4, , ] to have 3

This kind of problem that should be 3 channels and the result is 4 channels is generally due to the Image.open function.

Error statement:

img = Image.open(osp.join(dspth, image_path))

At this time, reading the picture is 4 channels, so an error will be reported.

It should be changed to:

 img = Image.open(osp.join(dspth, image_path)).convert('RGB')

Python: detect whether there is a problem with the pictures in a specified directory

When we use opencv to read pictures or use deep learning to read data sets, if there are problems with pictures, it will cause errors!

How to detect if all pictures in a folder are correct? The following code is summarized here.


Summary of SPAD photon detector usage

Here is a summary of the errors and experiences of using SPAD Detector (SPCM AQRH series):


1. Remove the black protective sleeve before use

This should be considered as common sense. But at the beginning, I didn't know it so that no data was obtained;


2. Note the enable termination high

The enable should be tied high to enable counting.

3. Pay attention to the focal length of the lens

The focal length of the front lens of the detector should be exactly equal to the distance of the lens from the detection hole, and fine-tuned to get the best detection structure.

4. Pay attention to height

The detector and laser must be aligned, otherwise the detection result will have an unexpectedly bad effect.

5. When buying, you should buy all the accessories

When purchasing, you should discuss the distribution requirements of the fixed components with the agent / producer in advance to facilitate subsequent installation and calibration.

Image Segmentation: Summary of Problems

1. Number of categories (label_nc / num_class)


Errors include:
RuntimeError: cuDNN error: CUDNN_STATUS_EXECUTION_FAILED

And other weird errors

Causes and solutions:
Imresize the label image

The default bilinear interpolation method almost inevitably generates new pixels, causing more classification problems and causing errors.

Solution: 
label = cv2.resize (label, (256,256), interpolation = cv2.INTER_NEAREST)

Use INTER_NEAREST interpolation.

Note: The method to view the number of labels: length (np.unique (label))

To be continued

Image segmentation / super pixel / parsing Github:

Face segmentation: https://github.com/zllrunning/face-parsing.PyTorch
Traditional method super pixel: https://github.com/mingyuliutw/EntropyRateSuperpixel
Generate real scene from segmentation graph: https://github.com/NVlabs/SPADE
Deeplab v3 + Pytorch version: https://github.com/jfzhang95/pytorch-deeplab-xception
CSAILVison Pytorch semantic segmentation: https://github.com/CSAILVision/semantic-segmentation-pytorch

Python: batch copy missing files with same name

Function: Batch copy missing files with the same name from other folders

# _*_ encoding:utf-8 _*_
import os
import sys
from shutil import copyfile

origin_A_train_path = './animeFaces/A/train/'
origin_A_test_path = './animeFaces/A/test/'

################################transfer training set #####################################
mode = 'train'
target_B_train_path = './data_superpixel_specifiedColor/B/'+mode+'/'
C_train_path = './data_superpixel_specifiedColor/C/'+mode+'/'
B_trainfile_name = os.listdir(target_B_train_path)
for image_index in range(len(B_trainfile_name)):
    image_name = B_trainfile_name[image_index]
    origin_image_file = origin_A_train_path + image_name
    if not os.path.exists(origin_image_file):
        print('test')
        origin_image_file = origin_A_test_path + image_name
    C_image_file = C_train_path + image_name
    copyfile(origin_image_file,C_image_file)


MATLAB: batch process pictures under specified path and save to another path


Function: Read all png files in a certain path, save them to another path by the original file name after batch processing



file_path =  './seeprettyface_models/';
img_path_list = dir(strcat(file_path,'*.png'));
dist_path = './chaomo/';


filePathTry = 'G:\Face\B_try\B_try';
filePathBtest = 'G:\Face\B_try\B\test';
filePathBtrain = 'G:\Face\B_try\B\train';
filePathBval = 'G:\Face\B_try\B\val';
filePathAtest = 'G:\Face\B_try\A\test';
filePathAtrain = 'G:\Face\B_try\A\train';
filePathAval = 'G:\Face\B_try\A\val';

h = waitbar(0,'Moving..., please wait');
% train
for im =1:length(img_path_list)
    fileName = img_path_list(im).name;
    filePath =  img_path_list(im).folder;
    fileImage = strcat(filePath,'\',fileName);
    distImage = strcat(dist_path,'\',fileName);
    image = imread(fileImage);
    image = imresize(image,[256,256]);
    imwrite(image,distImage);
    str = ['Moving image...',num2str(im*100/length(img_path_list)),'%'];
    waitbar(im/length(img_path_list),h,str)
end

MATLAB: train, test, val inedx number generation function


Function: Randomly draw 1% of integers between [1, N] into val; 1% into test; the rest into train

N = 10000;

A = [1:N]; 
A_temp = A;
val = [];
test = [];

% val
while length(val)<floor(N/100)
    temp = 1+floor(N.*rand(1));
    if ismember(temp,A_temp)
        val = [val, temp];
        A_temp = setdiff(A_temp,temp);
    end
end

% test
while length(test)<floor(N/100)
    temp = 1+floor(N.*rand(1));
    if ismember(temp,A_temp)
        test = [test, temp];
        A_temp = setdiff(A_temp,temp);
    end
end

% train
train = A_temp;

% sort()
test = sort(test);
val = sort(val);
train = sort(train);

Tensorboard:PermissionError: [Errno 13] Permission denied: '/tmp/.tensorboard-info/pid-20281.info'

Permission error when running TensorBoard:

PermissionError: [Errno 13] Permission denied: '/tmp/.tensorboard-info/pid-20281.info'


How to use RIGOL arbitrary function generator to generate arbitrary waveform

I bought a RIGOL function generator, but I don't know how to make it generate a custom irregular periodic signal. Here's how to generate it:


Server config file ./bashrc: reset and restore

When using a server, there may be unexpected situations such as the configuration file /.bashrc being suddenly emptied. This article documents the recovery steps for /.bashrc.