Skip to content
Guides5 min read

Migrer de Label Studio vers Potato

Guide pas à pas pour convertir manuellement les projets, modèles et annotations Label Studio au format Potato.

Potato Team·

Migrer de Label Studio vers Potato

Ce guide vous aide à migrer manuellement des projets Label Studio existants vers Potato. La migration implique de convertir les configurations à la main et d'écrire des scripts Python pour transformer vos formats de données.

Notez qu'il n'existe pas d'outil de migration officiel - c'est un processus manuel qui nécessite de comprendre les deux plateformes.

Pourquoi migrer ?

Potato offre des avantages pour certains cas d'utilisation :

  • Orienté recherche : Conçu pour les études d'annotation académiques
  • Crowdsourcing : Intégration native avec Prolific et MTurk
  • Simplicité : Configuration basée sur YAML, pas de base de données requise
  • Personnalisation : Facile à étendre avec Python
  • Léger : Stockage basé sur des fichiers, facile à déployer

Aperçu de la migration

La migration est un processus manuel comportant ces étapes :

  1. Convertir manuellement le modèle XML Label Studio en configuration YAML Potato
  2. Écrire des scripts Python pour transformer le format des données (JSON vers JSONL)
  3. Écrire des scripts pour migrer les annotations existantes (le cas échéant)
  4. Tester minutieusement et valider vos données converties

Conversion de modèles

Classification de texte

XML Label Studio :

xml
<View>
  <Text name="text" value="$text"/>
  <Choices name="sentiment" toName="text" choice="single">
    <Choice value="Positive"/>
    <Choice value="Negative"/>
    <Choice value="Neutral"/>
  </Choices>
</View>

YAML Potato :

yaml
annotation_task_name: "Sentiment Classification"
 
data_files:
  - "data/items.jsonl"
 
item_properties:
  id_key: id
  text_key: text
 
annotation_schemes:
  - annotation_type: radio
    name: sentiment
    description: "What is the sentiment?"
    labels:
      - name: positive
        tooltip: "Positive sentiment"
      - name: negative
        tooltip: "Negative sentiment"
      - name: neutral
        tooltip: "Neutral sentiment"

Classification multi-étiquettes

XML Label Studio :

xml
<View>
  <Text name="text" value="$text"/>
  <Choices name="topics" toName="text" choice="multiple">
    <Choice value="Politics"/>
    <Choice value="Sports"/>
    <Choice value="Technology"/>
    <Choice value="Entertainment"/>
  </Choices>
</View>

YAML Potato :

yaml
annotation_schemes:
  - annotation_type: multiselect
    name: topics
    description: "Select all relevant topics"
    labels:
      - name: politics
        tooltip: "Politics content"
      - name: sports
        tooltip: "Sports content"
      - name: technology
        tooltip: "Technology content"
      - name: entertainment
        tooltip: "Entertainment content"

Reconnaissance d'entités nommées

XML Label Studio :

xml
<View>
  <Labels name="entities" toName="text">
    <Label value="PERSON" background="#FFC0CB"/>
    <Label value="ORG" background="#90EE90"/>
    <Label value="LOCATION" background="#ADD8E6"/>
  </Labels>
  <Text name="text" value="$text"/>
</View>

YAML Potato :

yaml
annotation_schemes:
  - annotation_type: span
    name: entities
    description: "Select entity spans in the text"
    labels:
      - name: PERSON
        tooltip: "Person names"
      - name: ORG
        tooltip: "Organization names"
      - name: LOCATION
        tooltip: "Location names"

Note : L'annotation par span de Potato peut utiliser un surlignage différent de Label Studio. Testez votre configuration convertie pour vérifier que l'affichage correspond à vos besoins.

Échelles de notation

XML Label Studio :

xml
<View>
  <Text name="text" value="$text"/>
  <Rating name="quality" toName="text" maxRating="5"/>
</View>

YAML Potato :

yaml
annotation_schemes:
  - annotation_type: likert
    name: quality
    description: "Rate the quality"
    size: 5
    labels:
      - name: "1"
        tooltip: "Poor"
      - name: "2"
        tooltip: "Below average"
      - name: "3"
        tooltip: "Average"
      - name: "4"
        tooltip: "Good"
      - name: "5"
        tooltip: "Excellent"

Conversion du format de données

JSON Label Studio vers JSONL Potato

Format Label Studio :

json
[
  {
    "id": 1,
    "data": {
      "text": "This is great!",
      "meta_info": "source1"
    }
  },
  {
    "id": 2,
    "data": {
      "text": "This is terrible.",
      "meta_info": "source2"
    }
  }
]

Format JSONL Potato :

json
{"id": "1", "text": "This is great!", "metadata": {"source": "source1"}}
{"id": "2", "text": "This is terrible.", "metadata": {"source": "source2"}}

Script de conversion

python
import json
 
def convert_label_studio_to_potato(ls_file, potato_file):
    """Convert Label Studio JSON to Potato JSONL"""
 
    with open(ls_file, 'r') as f:
        ls_data = json.load(f)
 
    with open(potato_file, 'w') as f:
        for item in ls_data:
            potato_item = {
                "id": str(item["id"]),
                "text": item["data"].get("text", ""),
            }
 
            # Convert nested data fields
            if "data" in item:
                for key, value in item["data"].items():
                    if key != "text":
                        if "metadata" not in potato_item:
                            potato_item["metadata"] = {}
                        potato_item["metadata"][key] = value
 
            # Handle image URLs
            if "image" in item.get("data", {}):
                potato_item["image_url"] = item["data"]["image"]
 
            f.write(json.dumps(potato_item) + "\n")
 
    print(f"Converted {len(ls_data)} items")
 
# Usage
convert_label_studio_to_potato("label_studio_export.json", "data/items.jsonl")

Correspondance des fonctionnalités

Label StudioPotato
Choices (single)radio
Choices (multiple)multiselect
Labelsspan
Ratinglikert
TextAreatext
RectangleLabelsbounding_box
PolygonLabelspolygon
Taxonomy(utiliser multiselect imbriqué)
Pairwisecomparison

Liste de vérification de migration

  • Exporter les données de Label Studio (format JSON)
  • Convertir manuellement le modèle XML en YAML Potato
  • Écrire et exécuter des scripts Python pour transformer le format des données (JSON vers JSONL)
  • Écrire et exécuter des scripts pour convertir les annotations existantes (le cas échéant)
  • Configurer la structure du projet Potato
  • Tester avec des données d'exemple
  • Valider que les données converties correspondent à l'original
  • Former les annotateurs à la nouvelle interface
  • Exécuter un lot d'annotation pilote

Besoin d'aide pour migrer ? Consultez la documentation complète ou contactez-nous sur GitHub.