12/19/2021

semantic segmentation vs instance segmentation

 




* semantic segmentation
Finding out which class each pixel belongs to

* instance segmentation
To find out the pixel position of a detected object class based on object detection(localisation)

Is that confuse? ^^

Thank you.
πŸ™‡πŸ»‍♂️

www.marearts.com

12/13/2021

docker MongoDB pull and run

 

#pull image

docker pull mongodb

#run container

docker run --name mongodb -d -p 27017:27017 mongo


ex) access in python 

import pymongo # package for working with MongoDB
client = pymongo.MongoClient("mongodb://localhost:27017/")


Thank you.

www.marearts.com


12/10/2021

Retrive docker container IP address



replace 'container_name_or_id' -> 'you id or container name'

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id

Thank you.

mongodb python, Table recode export, loading, save csv, load csv

 refer to below code:


.

#connet db
client = pymongo.MongoClient("mongodb://localhost:27017/")
#connet table
who_table = db["who_table"]

#delete all
who_table.drop()

#load csv to table
df = pd.read_csv('1.csv')
data = df.to_dict('records')
who_table.insert_many(data)
#show all items
for x in who_table.find():
print(x)

#save table to csv
cursor = who_table.find({})
df = pd.DataFrame(list(cursor))
df.to_csv('2.csv', index=False)

.


Thank you.πŸ™‡πŸ»‍♂️

www.marearts.com


12/09/2021

IP 2 Geometry information python

 Here is official page:

https://pypi.org/project/ip2geotools/

https://github.com/tomas-net/ip2geotools


This is my try

..

# pip install ip2geotools
from ip2geotools.databases.noncommercial import DbIpCity
response = DbIpCity.get('165.132.116.105', api_key='free')
print(response)

..

The results :

165.132.116.105

Seodaemun-gu

Seoul

KR

37.5790747

126.9367861


Thank you. πŸ™‡πŸ»‍♂️

www.marearts.com


12/08/2021

increase number in dynamodb field key value

 

Get Access permission

.

import boto3
##########################################################
ACCESS_KEY = 'xxxx'
SECRET_KEY = 'xxx'
dynamo_client = boto3.client('dynamodb',
aws_access_key_id = ACCESS_KEY,
aws_secret_access_key = SECRET_KEY
)

.


sample code

.

#update when db
def update_when_db(who, when):
dynamo_client.update_item(
TableName='president_when', #table name
Key={'when': {'S': when}}, #primary key filed name, #key value, if key file not exist, it will create
UpdateExpression="ADD #counter :increment",
ExpressionAttributeNames={'#counter': who}, #key filed name that you want to increase
ExpressionAttributeValues={':increment': {'N': '1'}} #increase 1
)

.


Thank you.

πŸ™‡πŸ»‍♂️


www.marearts.com




Rotation(orientation) correction when uploading photos from mobile (python, pillow)

 Try to use ImageOps function.

Solution is simple refer to below code:

.

#pip install Pillow
from PIL import Image, ImageOps
image = Image.open('img.jpg') #open image
#### orient fix
image = ImageOps.exif_transpose(image)
#### go futher!

.


Thank you.

πŸ™‡πŸ»‍♂️

www.marearts.com


12/06/2021

Signature & Handwritten Detector on document image

Handwritten & Signature Detector on Document Image


* Live Demo

✍🏼 Signature & Handwritten Detector on Document

http://signhand.marearts.com/


* API explanation

https://www.marearts.com/Signature-Handwritten-Detector-c81f875ddb66490a8db990b50ce6f665


----------------------------------------

🌷 MareArts Free API List 🌷

MareArts 🎬 Live 

http://live.marearts.com


✍🏼 Signature & Handwritten Detector on Document

http://signhand.marearts.com/


πŸš™ Auto Number Plate Recognition - Korean

http://redkongkr.marearts.com/


🚦 Car License Plate detector

http://lpdetector.marearts.com/


🏳️‍🌈 Representative Color Extractor

http://recolor.marearts.com/


πŸ““ OCR Tess-v5

http://tessv5.marearts.com/


πŸ“ Regular Expression Generator

http://regular.marearts.com/


🐠 QRcode Generator

http://qr.marearts.com/


🦧 Barcode Generator

http://barcode.marearts.com/


🌊 Elastic Image Generator

http://elastic.marearts.com/


🏁 Mosaic Image Generator

http://mosaic.marearts.com/


⚽️ PDF to IMG convertor

http://pdf2img.marearts.com/


πŸ€ PDF to TXT convertor

http://pdf2txt.marearts.com/


🏈 PDF to HTML convertor

http://pdf2html.marearts.com/


⚾️ PDF to JSON convertor

http://pdf2json.marearts.com/


πŸ™‡πŸ»‍♂️ Thank you!

https://www.marearts.com

-----------------------------------

12/02/2021

How to combine multiple criterions to a loss function? Multiple loss function for single model.

You can simply reference below code:


ex1)

b = nn.MSELoss()(output_x, x_labels) a = nn.CrossEntropyLoss()(output_y, y_labels) loss = a + b loss.backward()


ex2)

b = nn.MSELoss() a = nn.CrossEntropyLoss() loss_a = a(output_x, x_labels) loss_b = b(output_y, y_labels) loss = loss_a + loss_b loss.backward()


And there are many opinions in here:

https://discuss.pytorch.org/t/how-to-combine-multiple-criterions-to-a-loss-function/348/27


Thank you.

www.marearts.com

πŸ™‡πŸ»‍♂️

12/01/2021

pdf2img, pdf to image, python library

 way #1

--

# pip install pdf2image
from pdf2image import convert_from_path
pdffile = '2081033884.pdf'
pages = convert_from_path(pdffile, 500)
#Saving pages in jpeg format
for i, page in enumerate(pages):
page.save(f'pdf2image_{i}.jpg', 'JPEG')

--



way #2

--

#pip install pymupdf
import fitz
pdffile = '2081033884.pdf'
doc = fitz.open(pdffile)
#split pages
for i, page in enumerate(doc.pages()):
pix = page.get_pixmap()
img_filename = f"fitz_{i}.jpg"
pix.pil_save(img_filename, format="jpeg", dpi=(300,300)) #, ... more PIL parameters)

--


Thank you.

www.marearts.com

πŸ™‡πŸ»‍♂️