SSL Configuration using Java Keystore and Label Studio Guide: Difference between pages

From LogicalDOC Community Wiki
(Difference between pages)
Jump to navigationJump to search
 
Giuseppe (talk | contribs)
No edit summary
 
Line 1: Line 1:
==SSL Configuration==
= Preparing a Dataset with Label Studio =


LogicalDOC embeds the Tomcat application server and it can be configured to support the encrypted protocol HTTPS. This is useful when you want to expose the program on the Internet.
This guide explains how to create an annotated dataset for YOLO training using Label Studio.
Basically you only have to follows the steps described in the Apache how-to at [https://tomcat.apache.org/tomcat-8.0-doc/ssl-howto.html|SSL Configuration HOW-TO]


What follows is a re-visioned extract from that how-to
Install Label Studio using pip:


== Prepare the certificate Keystore ==
<pre>
To install and configure SSL support on Tomcat, you need a keystore that is a file containing one or more certificates
pip install label-studio
Tomcat currently operates on JKS format keystores. The JKS format is Java's standard "Java KeyStore" format, and is the format created by the keytool command-line utility. This tool is included in the JDK.
</pre>


Each entry in a keystore is identified by an alias string.
Verify the installation:
To import an existing certificate into a JKS keystore, please read the documentation (in your JDK documentation package) about keytool.


To create a new keystore from scratch, containing a single self-signed Certificate, execute the following from a terminal command line:
<pre>
python -m label_studio.server --help
</pre>


Windows:<br/>
Or refer to the official installation guide:
    %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA
https://labelstud.io/guide/install
<br/>
Unix:<br/>
    $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA
<br/>
(The RSA algorithm should be preferred as a secure algorithm, and this also ensures general compatibility with other servers and components.)


This command will create a new file, in the home directory of the user under which you run it, named ".keystore". To specify a different location or filename, add the -keystore parameter, followed by the complete pathname to your keystore file, to the keytool command shown above. You will also need to reflect this new location in the server.xml configuration file, as described later. For example:


Windows:<br/>
=== Enable Local File Storage ===
    %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA \
      -keystore \path\to\my\keystore
<br/>
Unix:<br/>
    $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA \
      -keystore /path/to/my/keystore


After executing this command, you will first be prompted for the keystore password. The default password used by Tomcat is "changeit" (all lower case), although you can specify a custom password if you like. You will also need to specify the custom password in the server.xml configuration file, as described later.
For large projects it is not recommended to upload images directly through the Label Studio interface. Instead, configure a local directory that contains the images to annotate.


Next, you will be prompted for general information about this Certificate, such as company, contact name, and so on. This information will be displayed to users who attempt to access a secure page in your application, so make sure that the information provided here matches what they will expect.
To enable local file access, configure the following environment variables before starting Label Studio:


Finally, you will be prompted for the key password, which is the password specifically for this Certificate (as opposed to any other Certificates stored in the same keystore file). You <b>MUST</b> use the same password here as was used for the keystore password itself. (Currently, the keytool prompt will tell you that pressing the ENTER key does this for you automatically.)
<pre>
LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED=true
LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT=/path/to/images
</pre>


If everything was successful, you now have a keystore file with a Certificate that can be used by your server.


==Edit the Tomcat configuration file==   
The final step is to configure your secure socket in the $CATALINA_BASE/conf/server.xml file, where $CATALINA_BASE represents the base directory for the Tomcat 6 instance. An example <Connector> element for an SSL connector is included in the default server.xml file installed with Tomcat. It will look something like this:


    <-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
    <Connector
              port="8443" minSpareThreads="5" maxSpareThreads="75"
              enableLookups="true" disableUploadTimeout="true"
              acceptCount="100"  maxThreads="200"
              scheme="https" secure="true" SSLEnabled="true"
              keystoreFile="${user.home}/.keystore" keystorePass="changeit"
              clientAuth="false" sslProtocol="TLS"/>
   
You will note that the Connector element itself is commented out by default, so you will need to remove the comment tags around it. Then, you can customize the specified attributes as necessary.


The port attribute (default value is 8443) is the TCP/IP port number on which Tomcat will listen for secure connections. You can change this to any port number you wish.
=== Starting Label Studio ===


If you change the port number here, you should also change the value specified for the redirectPort attribute on the non-SSL connector. This allows Tomcat to automatically redirect users who attempt to access a page with a security constraint specifying that SSL is required, as required by the Servlet 2.4 Specification.
Label Studio can be started using one of the following methods.


After completing these configuration changes, you must restart Tomcat as you normally do, and you should be in business. You should be able to access LogicalDOC via SSL. For example, try:


    https://localhost:8443
==== Default Startup ====


and you should see the usual login page.
If local file storage is not required, Label Studio can be started with the default configuration:


==Importing a certificate==
<pre>
Please note that each certificate issuer is different and the procedure to install their certificates in Tomcat may be differ.
label-studio start
</pre>


<u>It is responsibility fo your certificate issuer to provide you with a tutorial on installing the certificate in Tomcat. So refer to your certificate issuer for getting help</u>.
or


For your convenience, here below is a list of How-Tos from different issuers:
<pre>
* GoDaddy: https://www.godaddy.com/help/tomcat-generate-csrs-and-install-certificates-5239
python -m label_studio.server start
* Thawte: https://search.thawte.com/support/ssl-digital-certificates/index?page=content&id=SO14873
</pre>


By default, the application is available at:


In general, if you have your Certificate you can import it into you local keystore. First of all you have to import a so called Chain Certificate or Root Certificate into your keystore.
<pre>
After that you can proceed with importing your Certificate.
http://localhost:8080
</pre>


* Download a Chain Certificate from the Certificate Authority you obtained the Certificate from.
==== Startup with Local File Storage ====
  For Entrust commercial certificates go to: http://www.entrust.net
 
  For Verisign commercial certificates go to: http://www.verisign.com/support/install/intermediate.html
When working with large datasets, it is recommended to configure Local Storage so that images are accessed directly from the filesystem.
  For Thawte go to: http://www.thawte.com/certs/trustmap.html
 
  For GoDaddy go to: https://www.godaddy.com/help/tomcat-generate-csrs-and-install-certificates-5239
Windows example:
* Import the Chain Certificate into your keystore
 
          keytool -import -alias root -keystore <your_keystore_filename> \
<pre>
          -trustcacerts -file <filename_of_the_chain_certificate>
set LABEL_STUDIO_PORT=8081
* And finally import your new Certificate
set LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED=true
          keytool -import -alias tomcat -keystore <your_keystore_filename> \
set LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT=C:\Users\username\Documents\label-studio
          -file <your_certificate_filename>
 
python -m label_studio.server start
</pre>
 
After startup, Label Studio will be available at:
 
<pre>
http://localhost:8081
</pre>
 
The directory specified by '''LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT''' can then be configured as Local Storage within a Label Studio project.
 
Port '''8081''' is used to avoid conflicts with the default LogicalDOC installation, which typically runs on port '''8080'''.
 
 
=== Create a Project ===
 
# Login to Label Studio
# Click '''Create Project'''
# Enter a project name
# Configure the labeling interface
# Save the project
 
=== Import Images ===
 
# Open the project
# Click '''Import'''
# Select '''Local Storage'''
 
=== Configure Local Storage ===
 
# Open the project
# Navigate to '''Settings > Cloud Storage'''
# Click '''Add Source Storage'''
# Select '''Local Files'''
# Configure the path specified by LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT
# Click '''Sync Storage'''
 
 
[[File:local-storage-button.png|thumb|800px|center|Local Storage button]]
[[File:Storage-Settings-Label-Studio.png|thumb|800px|center|Local Storage Selection]]
[[File:LabelStudio-local-storage.png.png|thumb|800px|center|Local Storage configuration showing a synchronized directory of document images]]
 
 
After synchronization, Label Studio automatically creates one task for each imported document image.
 
When importing images, choose '''Files''' as the import method.
 
=== Annotate Documents ===
 
# Open a task
# Select a label
# Draw a bounding box around the target area
# Save the annotation
 
Example labels:
 
* Invoice Number
* Date
* Seller Name
* Buyer Name
* Total Amount
 
[[File:LabelStudio-annotation-example.png|thumb|600px|center|Example annotation]]
 
=== Export the Dataset ===
 
# Open the project
# Click '''Export'''
# Select the desired format
 
Supported formats include:
 
* YOLO
* COCO
* Pascal VOC
* CSV
 
For YOLO training, export the dataset in YOLO format.
 
=== Dataset Formats ===
 
==== COCO ====
 
COCO is a JSON-based dataset format commonly used for object detection datasets.
 
More information:
https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/md-coco-overview.html
 
==== YOLO ====
 
YOLO datasets contain images and annotation files organized according to a predefined directory structure.
 
More information:
https://docs.cvat.ai/docs/dataset_management/formats/format-yolo/
 
==== YOLOv8 OBB ====
 
YOLOv8 OBB (Oriented Bounding Boxes) extends the standard YOLO format by supporting rotated bounding boxes using eight normalized coordinates.

Revision as of 13:12, 23 June 2026

Preparing a Dataset with Label Studio

This guide explains how to create an annotated dataset for YOLO training using Label Studio.

Install Label Studio using pip:

pip install label-studio

Verify the installation:

python -m label_studio.server --help

Or refer to the official installation guide: https://labelstud.io/guide/install


Enable Local File Storage

For large projects it is not recommended to upload images directly through the Label Studio interface. Instead, configure a local directory that contains the images to annotate.

To enable local file access, configure the following environment variables before starting Label Studio:

LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED=true
LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT=/path/to/images



Starting Label Studio

Label Studio can be started using one of the following methods.


Default Startup

If local file storage is not required, Label Studio can be started with the default configuration:

label-studio start

or

python -m label_studio.server start

By default, the application is available at:

http://localhost:8080

Startup with Local File Storage

When working with large datasets, it is recommended to configure Local Storage so that images are accessed directly from the filesystem.

Windows example:

set LABEL_STUDIO_PORT=8081
set LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED=true
set LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT=C:\Users\username\Documents\label-studio

python -m label_studio.server start

After startup, Label Studio will be available at:

http://localhost:8081

The directory specified by LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT can then be configured as Local Storage within a Label Studio project.

Port 8081 is used to avoid conflicts with the default LogicalDOC installation, which typically runs on port 8080.


Create a Project

  1. Login to Label Studio
  2. Click Create Project
  3. Enter a project name
  4. Configure the labeling interface
  5. Save the project

Import Images

  1. Open the project
  2. Click Import
  3. Select Local Storage

Configure Local Storage

  1. Open the project
  2. Navigate to Settings > Cloud Storage
  3. Click Add Source Storage
  4. Select Local Files
  5. Configure the path specified by LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT
  6. Click Sync Storage


Local Storage button
Local Storage Selection
Local Storage configuration showing a synchronized directory of document images


After synchronization, Label Studio automatically creates one task for each imported document image.

When importing images, choose Files as the import method.

Annotate Documents

  1. Open a task
  2. Select a label
  3. Draw a bounding box around the target area
  4. Save the annotation

Example labels:

  • Invoice Number
  • Date
  • Seller Name
  • Buyer Name
  • Total Amount
File:LabelStudio-annotation-example.png
Example annotation

Export the Dataset

  1. Open the project
  2. Click Export
  3. Select the desired format

Supported formats include:

  • YOLO
  • COCO
  • Pascal VOC
  • CSV

For YOLO training, export the dataset in YOLO format.

Dataset Formats

COCO

COCO is a JSON-based dataset format commonly used for object detection datasets.

More information: https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/md-coco-overview.html

YOLO

YOLO datasets contain images and annotation files organized according to a predefined directory structure.

More information: https://docs.cvat.ai/docs/dataset_management/formats/format-yolo/

YOLOv8 OBB

YOLOv8 OBB (Oriented Bounding Boxes) extends the standard YOLO format by supporting rotated bounding boxes using eight normalized coordinates.