How can I save the segmentation result of segnet - caffe

scipy.misc.toimage(rgb, cmin=0.0, cmax=255).save(IMAGE_FILE+'_segnet.png')
In the file test_segmentation_camvid, how should I define the IMAGE_FILE and save the prediction results?

IMAGE_FILE is just a variable that would be the name of the saved image
you can do something like
IMAGE_FILE="new_image"
scipy.misc.toimage(rgb, cmin=0.0, cmax=255).save(IMAGE_FILE+'_segnet.png')
and the image that would be saved will be under the name new_image_segnet.png

Related

Jinja2 read file

I am using Jinja2 templates to create configs. I am trying to reverse the process, to read the contents of a file and store the variables.
For example,
If I have a file containing the following:
!
interface gi0/0
**random stuff**
description first desc
**random stuff**
!
interface gi0/1
description second desc
**random stuff**
!
Can I create a template as below and use it to read the files and store the variables?
interface {{INTERFACE}}
description {{DESCRIPTION}}
So I would end up with something like this:
(interface:"gi0/0",description:"first desc"),
(interface:"gi0/1",description:"second desc")

Expecting value: line 1 column 1 (char 0) problem

i want json file open for object detection (yolo v5 or yolo v7)
so i have 51 ten thousand images and json labeling data
enter image description here
but i don't solve this problem (i tried googleing but yet...)
jupyter notebook not print this problem
i think be a major cause
json file problem
or
enter image description here
colab memory issue
so how i solev this problem?
please help me
You are possibly using the open function wrongly. Now don't quote me on this but if you are trying to read data from a JSON file you would need to use the key word 'r' like so:
with open(filename, 'r') as f:
data = json.load(f)
'r' stands for read.

PYAUTOGUI IN FOR LOOP Python

I am trying to do a series of steps on each file in the directory. For each file, I want to copy the name of the file and then paste it at specified coordinates on the screen. The first three lines of code in the if statement seem to get ignored and all I see happen is the cursor move to the destination. None of the file names are getting copied to the clipboard and none are pasted. Please see error picture message attached. Any advice is much appreciated.
pythonPicError
import pyautogui,os
directory = 'C:\\Users\\johna\\Desktop\\pdfs'
for filename in os.listdir(directory):
if filename.endswith('.txt'):
pyautogui.click()
pyautogui.press('f2') #select file name
pyautogui.hotkey('ctrl','c') #copy file name
pyautogui.moveTo(153,1054,duration=2)
pyautogui.click() #click on destination
pyautogui.hotkey('ctrl','v') #paste file name
Print something after each line of code, to see where exactly is the problem. But I guess
pyautogui.hotkey('ctrl','c') #copy file name
ctrl+c is just killing your script :)
Just noticed:
pyautogui.click()
You didn't provide any coords for this click, so it's clicking just after you run the program in the place where your coursor is.
I programmed coordinates and now it works.
import pyautogui,os
directory = 'C:\\Users\\johna\\Desktop\\pdfs'
x=226
y=280
for filename in os.listdir(directory):
if filename.endswith('.txt'):
pyautogui.click(x,y)
pyautogui.press('f2')
pyautogui.hotkey('ctrl','c')
y=y+30
pyautogui.moveTo(107,559,duration=2)
pyautogui.click()
pyautogui.hotkey('ctrl','v')

Transforming csv file headers

I have a csv file with more number of headers. Each time I am getting this file, I wish to change the name of the headers.
Sample File:
Name Price .....
Cat 5000
Dog 8000
I wish to change the header name "Price" to "Rate". I can't do it manually each time. Is there any automation tool available so that i can feed in the required changes and the file which will inturn return the file after the applied changes.
Thanks

MATLAB: How to read blob data from MySQL, and save as image?

I have a bunch of images stored as blob data in database, now I would like to read(retrieve) these images from mysql using MATLAB, then do further image processing. However, the problem is: retrieved data is a N*1 unit8 vector, which can not be used for image feature (such as SIFT) extraction implementation. The following is my code:
conn = database.ODBCConnection('test','username','password');
curs = exec(conn,'select image from roomimage'); % image is the column of saved blob data, and roomimage is the table in database
curs = fetch(curs);
img=curs.Data{1,1}; % as and example, read the first image
Then I get class(img)=unit8, size is 111365*1
Then if I write and save as image file:
imwrite(img,'test.jpg')
imwrite(img,'test.png') % alternatively, I also tried to save it as .png file
Here comes the problem: the saved file cannot be opened! :(
Could someone show me, when using MATLAB, how to read blob data from mysql, save it as .jpg file, which can be opened as an image? Thank you very much!!!
#
Add: if I export and save image from mysql beforehand, then load image from local file to MATLAB, I get something like:683*1024*3 unit8 data, which is NOT like the N*1 vector read from mysql...