Installation api object detection - tensorflow

I install api object detection, it's take a lot of space, please tell me which files to save for just detect objects on images, Thanks you.

You need utils, protoc, and ipynb script
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
from distutils.version import StrictVersion
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
from utils import label_map_util
from utils import visualization_utils as vis_util
You can see this clearly from the https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb script that is on official repo. Install all the required libraries NumPy, os, etc .. and copy the utils directory

Related

How to solve Conv1D DNN library is not found?

How to solve the error Cnv1 DNN library not found in tensorflow?
And, are the compatibilities given by tensorflow here, https://www.tensorflow.org/install/source valid backwards as well?
This question is a possible duplicate to (certainly related to): Colab: (0) UNIMPLEMENTED: DNN library is not found and Unimplemented Error Node: 'sequential/conv1d/Conv1D' DNN library is not found running in Jupyter on Windows However, I could not quite follow their solution. Here is my problem:
I am training a convolutional neural network (CNN) with Keras/tensorflow. On my PC it appears to be running fine. However, I must get it to work on GPUs. And it is there that I am running into all sorts of issues. The latest:
Node: 'XXX/1st_Conv1D/Conv1D'
DNN library is not found.
[[{{node XXX/1st_Conv1D/Conv1D}}]] [Op:__interference_train_function_5577]
The XXX is name chosen by me in the code. The training starts fine and then abruptly aborts after some time with the above message.
I have installed conda (WITHOUT admin rights) on the GPU server (will not get amdin rights, its a univesity system).
conda list gives the following:
cudnn Version 8.4.1.50
keras Version 2.10.0
keras-preprocessing Version 1.1.2
tensorflow Version 2.10.0
tensorflow-base Version 2.10.0
tesnorflow-estimator Version 2.10.0
cuda-toolkit Version 12.0.0
cuda-tools Version 12.0.0
cuda-cudart Version 12.0.107
cuda-python Version 11.8.1
cudatoolkit Version 11.8
python Version 3.9.15
And various other packages (many cuda-something). (I have not installed bazel). The listed packages cudatoolkit and cuda-toolkit is not a typo. Neither is python nore cuda-python (from nvidia channel of anaconda). My understanding from https://www.tensorflow.org/install/source is that this should be fine. Some people mention some library paths. I don't get it. For this I need some more idiot-proof explanation :-( (Keep in mind, I have no admin rights)
In my python code I import the following:
from keras import backend as K
import tensorflow as tf
from tensorflow import keras
from keras import Input
from keras.models import Model
from keras.layers import BatchNormalization
from keras.layers import LeakyReLU
from keras.layers import Activation
from keras.layers import Dense
from keras.layers import Reshape
from keras.layers import Conv1D
from keras import initializers
from keras.callbacks import EarlyStopping
from keras.callbacks import ModelCheckpoint
from keras.callbacks import ReduceLROnPlateau
from keras.models import load_model
from keras.optimizers import Adam
from keras.utils import Sequence
from keras.metrics import MeanSquaredError
from keras.metrics import MeanAbsoluteError
from keras.metrics import RootMeanSquaredError
# for plotting
import matplotlib
# import matplotlib.pyplot as plt
matplotlib.use('Agg')
from matplotlib import pyplot as plt
import matplotlib.colors as mcolors
import matplotlib as mpl
import matplotlib.patches as mpatches
from matplotlib.colors import to_rgb
from matplotlib.collections import PolyCollection
from matplotlib.legend_handler import HandlerTuple
import seaborn as sns # for violin plots
I also import pandas, numpy, wave, time,sys,json,argparse, pathlib, datetime and random. They are not causing any problems so far.
The model is then trained with:
history = model.fit(x=train_data_gen,
validation_data=vali_data_gen,
batch_size=BATCH_SIZE,
epochs=EPOCHS,
verbose=VERBOSITY,
shuffle=SHUFFLE,
max_queue_size=QUEUE_SIZE,
use_multiprocessing=MULTI_PROCESSING,
workers=WORKERS,
callbacks=[early_stopping,
model_checking,
reduce_lr])
Where MULTI_PROCESSING is set to True (see: https://stanford.edu/~shervine/blog/keras-how-to-generate-data-on-the-fly). This works fine on a PC. But is obviously slow. I MUST get it to work on GPUs. Queue Size is set to 1000. And workers is 48. I can lower it. Some people suggested memory problems, though I cannot imagine that.
Any help is welcome. I am getting desparate! Thanks in advance.
The installed CUDA and cuDNN version in your system is not matching with the tested build configurations defined for the TensorFlow 2.10 GPU setup. (Check the image below)
You need to install the specified version of cuDNN 8.1 and CUDA 11.2 compatible to TensorFlow 2.10 to enable GPU support in your system.
Please check the link to install these software. Thank you.

matplotlib CGI doesn't work

I'd like to publish a figure generated by matplotlib on web site based on Windows Apache Server.
A Scipy example code (below) shows just tiny icon which link is broken.
The code of related question on this BBS also just shows icon.
My code is below. I guess the code is correct, but I probably mess up some setting of Apache Server or matplotlib. Any comments is welcome.
#!c:/python27/python
import os, sys
import cgi
import cgitb; cgitb.enable()
os.environ['HOME'] = r'C:\temp'
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
plt.plot([1,2,1,4,2,6,4,8])
print "Content-Type: image/png\n"
plt.savefig( sys.stdout, format='png' )

org.apache.http, org.apache.xerces

So im trying to import
import org.apache.http.HttpEntity
import org.apache.http.HttpResponse
import org.apache.http.client.HttpClient
import org.apache.http.client.methods.HttpPost
import org.apache.http.entity.StringEntity
import org.apache.http.impl.client.DefaultHttpClient
import org.apache.http.message.BasicHttpResponse
import org.apache.http.params.HttpParams
import org.apache.http.params.HttpConnectionParams
import org.apache.http.util.EntityUtils
import org.apache.xerces.impl.XMLEntityManager.Entity
Non of these are found. I have a different project that is importing the exact same things and it works. But not on this project. Any ideas on why this could be happening?
---------------------------------------------------
tomcat 2.1.0 -- Apache Tomcat plugin for Grails
webxml 1.4.1 -- WebXmlConfig
Any help would be greatly appreciated. Thanks!
A common problem is usually that the libraries (xerces) are not imported, you can download it from here.
Oficial web
Cheers.

Setting Matplotlib MPLCONFIGDIR: consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data

I am using Linux server to set up a django project. I got this error: "Failed to create /var/www/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data"
Then I found $MPLCONFIGDIR are empty. So I set it like this:
lab#base:~$ export MPLCONFIGDIR=~/website/graph
lab#base:~$ echo $MPLCONFIGDIR
/home/lab/website/graph
This path is the directory where I want to store images created by Matplotlib.
Then I made sure this setting in python command line:
>>> import matplotlib
>>> import os
>>> os.environ.get('MPLCONFIGDIR')
'/home/lab/website/graph'
BUT, in the django project which is deployed in Apache with mod_wsgi, the above-mentioned error still exits. I added the below lines:
import os
os.environ['MPLCONFIGDIR'] = "/home/lab/website/graph"
print(os.environ.get('MPLCONFIGDIR'))
It prints "None"!
Can anyone help me?
Thanks.
Set the MPLCONFIGDIR in code before you import matplotlib. Make sure the directory has permissions such that it can be written to by the app.
import os
os.environ['MPLCONFIGDIR'] = "/home/lab/website/graph"
import matplotlib
Alternatively, you could set it to a tempfile.
import os
import tempfile
os.environ['MPLCONFIGDIR'] = tempfile.mkdtemp()
import matplotlib
Per #Esteban I do something like this in modules or scripts:
import os
try:
import matplotlib
except:
import tempfile
import atexit
import shutil
mpldir = tempfile.mkdtemp()
atexit.register(shutil.rmtree, mpldir) # rm directory on succ exit
os.environ['MPLCONFIGDIR'] = mpldir
import matplotlib
This way the temporary directory is removed on exit.

UPS developer API missing ja

I am looking for what jar library to import into my software. I am using ups's Shipping_Pkg_Gnd.zip for a spring board to provide shipping label generation. However they did not provide a .jar library in any of sample code that they provide. Does anyone know where to get this library.
Here are the imports that will not work because I do not have the required developer API
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipmentErrorMessage;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.BillShipperType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.InternationalFormType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.LabelImageFormatType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.LabelSpecificationType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.PackageType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.PackageWeightType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.PackagingType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.PaymentInfoType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ProductType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ProductWeightType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.RequestType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ServiceAccessToken_type0;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ServiceType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ShipAddressType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ShipFromType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ShipPhoneType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ShipToAddressType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ShipToType;
import com.ups.www.wsdl.xoltws.ship.v1_1.ShipServiceStub.ShipUnitOfMeasurementType;
I had the similar issue, and the solution is to use wsimport.sh to generate the jar/class files from the wsdl.
So you have to copy the following six files to the same folder
$ mkdir ups_ship && cd ups_ship
$ ls -1
common.xsd
Error1.1.xsd
IFWS.xsd
ShipWebServiceSchema.xsd
Ship.wsdl
UPSSecurity.xsd
$ wsimport.sh -verbose -keep -extension -target 2.0 Ship.wsdl
Generated code:
$ ls -1 com/ups/wsdl/xoltws/ship/v1/
ShipAcceptErrorMessage.class
ShipAcceptErrorMessage.java
ShipConfirmErrorMessage.class
ShipConfirmErrorMessage.java
ShipmentErrorMessage.class
ShipmentErrorMessage.java
ShipPortType.class
ShipPortType.java
ShipService.class
ShipService.java
Now you can put all your *.class files in a package and use it in your project:
$jar cvf com_ups_wsdl_xoltws_ship_v1.jar ./com/ups/wsdl/xoltws/ship/v1/*.class
Your new jar:
$jar tf com_ups_wsdl_xoltws_ship_v1.jar
META-INF/
META-INF/MANIFEST.MF
com/ups/wsdl/xoltws/ship/v1/ShipAcceptErrorMessage.class
com/ups/wsdl/xoltws/ship/v1/ShipConfirmErrorMessage.class
com/ups/wsdl/xoltws/ship/v1/ShipmentErrorMessage.class
com/ups/wsdl/xoltws/ship/v1/ShipPortType.class
com/ups/wsdl/xoltws/ship/v1/ShipService.class