Skip to content

Instantly share code, notes, and snippets.

View VyBui's full-sized avatar

Vy Bui VyBui

  • Code Engine Studio
  • 295 Nguyễn Tất Thành Đà Nẵng, Việt Nam
View GitHub Profile
@VyBui
VyBui / bps_train
Created April 21, 2020 02:24
bps_train
import os
import time
import segmentation_models as sm
# Segmentation Models: using `keras` framework.
import tensorflow as tf
from tensorflow.python.client import device_lib
from config import cfg
from time import sleep
from json import dumps
from kafka import KafkaProducer
BPS_models = '/home/vybt/Downloads/release_official/full_flow_test/models.txt'
producer = KafkaProducer(bootstrap_servers=['localhost:9092'],
value_serializer=lambda x:
dumps(x).encode('utf-8'))
import logging
log = logging.getLogger(__name__)
from smart_fashion_client.api.request_util import extract_extension_for_key
from smart_fashion_client.s3_upload import helpers
#
from smart_fashion_client.api.body_parts_segmentation.logic.body_parts_segmentation import human_parsing_processing
from json import dumps
from kafka import KafkaProducer
1
after infer parsing: 1.249729871749878
/usr/local/lib/python3.6/dist-packages/tensorflow_serving/apis/prediction_service_pb2.py:131: DeprecationWarning: beta_create_PredictionService_stub() method is deprecated. This method will be removed in near future versions of TF Serving. Please switch to GA gRPC API in prediction_service_pb2_grpc.
'prediction_service_pb2_grpc.', DeprecationWarning)
/usr/local/lib/python3.6/dist-packages/tensorflow_serving/apis/prediction_service_pb2.py:131: DeprecationWarning: beta_create_PredictionService_stub() method is deprecated. This method will be removed in near future versions of TF Serving. Please switch to GA gRPC API in prediction_service_pb2_grpc.
'prediction_service_pb2_grpc.', DeprecationWarning)
total time module 2: 4.909551382064819
end time: 6.159325838088989
2
after infer parsing: 1.223271131515503
handling https://bap-fashion-shop.s3.amazonaws.com/11.jpg
for 1
End time for Body parts segmentation: 0.9372918605804443
[{'ownerId': 1, 'combineFeaturesURL': 'https://bap-fashion-shop.s3.amazonaws.com/user_id_1_combine_features_111586408310.png', 'schpURL': 'https://bap-fashion-shop.s3.amazonaws.com/user_id_1_SCHP_111586408311.png'}]
sending message [{'ownerId': 1, 'combineFeaturesURL': 'https://bap-fashion-shop.s3.amazonaws.com/user_id_1_combine_features_111586408310.png', 'schpURL': 'https://bap-fashion-shop.s3.amazonaws.com/user_id_1_SCHP_111586408311.png'}] out to: bpsOut
handling https://bap-fashion-shop.s3.amazonaws.com/womna_3.jpeg
for 2
End time for Body parts segmentation: 0.7253215312957764
[{'ownerId': 2, 'combineFeaturesURL': 'https://bap-fashion-shop.s3.amazonaws.com/user_id_2_combine_features_womna_31586408312.png', 'schpURL': 'https://bap-fashion-shop.s3.amazonaws.com/user_id_2_SCHP_womna_31586408312.png'}]
sending message [{'ownerId': 2, 'combineFeaturesURL': 'https://bap-fashion-shop.s3.am
import logging
log = logging.getLogger(__name__)
from api.request_util import extract_extension_for_key, get_kafka_comsumer
from s3_upload import helpers
from api.restplus import api
from api.body_parts_segmentation.logic.body_parts_segmentation import human_parsing_processing
from flask import request, jsonify
from flask_restplus import Resource
from __future__ import absolute_import, division, print_function, unicode_literals
import logging.config
import tensorflow as tf
import os
import numpy as np
from tensorflow import ConfigProto
from argument_parse import args
from module.discriminator_vgg19 import Discriminator
@VyBui
VyBui / Reovery_size
Last active December 12, 2019 03:19
resize padding and recovery image
import os
import cv2
original_image_path = '/home/vybt/Downloads/olk/rmbg_tiennv3/tiennv3_rmbg'
resize_padding_output = '/home/vybt/Downloads/olk/rmbg_tiennv3/deep_lab_tiennv3_resize_lookbook'
where_to_resize_from = '/home/vybt/Downloads/olk/rmbg_tiennv3/deep_lab_tiennv3_lookbook'
def resize_and_padding(im, desired_size):
"""
@VyBui
VyBui / tensorflow_finetune.py
Created November 27, 2019 10:04 — forked from omoindrot/tensorflow_finetune.py
Example TensorFlow script for fine-tuning a VGG model (uses tf.contrib.data)
"""
Example TensorFlow script for finetuning a VGG model on your own data.
Uses tf.contrib.data module which is in release v1.2
Based on PyTorch example from Justin Johnson
(https://gist.github.com/jcjohnson/6e41e8512c17eae5da50aebef3378a4c)
Required packages: tensorflow (v1.2)
Download the weights trained on ImageNet for VGG:
```
wget http://download.tensorflow.org/models/vgg_16_2016_08_28.tar.gz
@VyBui
VyBui / tensorflow_finetune.py
Created November 27, 2019 10:04 — forked from omoindrot/tensorflow_finetune.py
Example TensorFlow script for fine-tuning a VGG model (uses tf.contrib.data)
"""
Example TensorFlow script for finetuning a VGG model on your own data.
Uses tf.contrib.data module which is in release v1.2
Based on PyTorch example from Justin Johnson
(https://gist.github.com/jcjohnson/6e41e8512c17eae5da50aebef3378a4c)
Required packages: tensorflow (v1.2)
Download the weights trained on ImageNet for VGG:
```
wget http://download.tensorflow.org/models/vgg_16_2016_08_28.tar.gz