> For the complete documentation index, see [llms.txt](https://docs.unitlab.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.unitlab.ai/api-sdk-cli/hi/get-started/python-sdk-quickstart.md).

# Python SDK क्विकस्टार्ट

Unitlab Python SDK क्विकस्टार्ट: पाँच मिनट में ओन्टोलॉजी के साथ प्रोजेक्ट बनाएँ, इमेज का फ़ोल्डर अपलोड करें और बने हुए आइटम की सूची देखें।

लगभग पाँच मिनट में आप बाउंडिंग-बॉक्स ओन्टोलॉजी वाला प्रोजेक्ट बनाते हैं, इमेज का एक फ़ोल्डर अपलोड करते हैं और Unitlab के बनाए आइटम की सूची देखते हैं।

## शुरू करने से पहले <a href="#before-you-begin" id="before-you-begin"></a>

* [SDK इंस्टॉल करें](https://docs.unitlab.ai/api-sdk-cli/hi/get-started/install-the-python-sdk-and-cli.md) और [`UNITLAB_API_KEY` सेट करें](https://docs.unitlab.ai/api-sdk-cli/hi/get-started/authentication-and-api-keys.md)। key के पास **Manage projects**, **Manage ontologies** और **Manage data** परमिशन होनी चाहिए।
* स्क्रिप्ट के बगल में `images` नाम के फ़ोल्डर में कुछ JPG या PNG इमेज रखें।

```
warehouse-picks/
├── quickstart.py
└── images/
    ├── bin-001.jpg
    └── bin-002.jpg
```

## स्क्रिप्ट चलाएँ <a href="#run-the-script" id="run-the-script"></a>

इसे `quickstart.py` नाम से सेव करें और Python से चलाएँ।

```python
from pathlib import Path

from unitlab import OntologyStructure, RadioAttribute, Shape, UnitlabClient

client = UnitlabClient()  # reads UNITLAB_API_KEY
try:
    # 1. Describe what annotators will label.
    structure = OntologyStructure()
    item = structure.add_object("Item", Shape.BOUNDING_BOX)
    grasp = item.add_attribute(RadioAttribute, "Graspable", required=True)
    grasp.add_option("Yes")
    grasp.add_option("No")
    ontology = client.ontologies.create("Bin picking", structure=structure)

    # 2. Create a project that uses it.
    project = client.projects.create("Warehouse picks", ontology_hash=ontology.id)
    print("Project:", project.id)

    # 3. Upload the folder. One call creates one Batch Queue.
    batch = project.upload(Path(__file__).parent / "images")
    print(f"Uploaded {batch.uploaded} of {batch.total} files")
    for failure in batch.failed:
        print("Not uploaded:", failure.path, failure.error)

    # 4. Wait until the server has processed every file.
    status = batch.wait(timeout=1800)
    print(f"Processed: {status.completed}, failed: {status.failed}")

    # 5. List the items in this upload.
    for unit in project.data_units(batch_queue=batch.batch_queue_id):
        print(unit.name, unit.data_type, unit.status)
finally:
    client.close()
```

आपको कुछ ऐसा आउटपुट दिखेगा। टर्मिनल में `batch.wait()` एक प्रोग्रेस बार भी दिखाता है।

```
Project: 7c9e6679-7425-40de-944b-e07fc1f90ae7
Uploaded 2 of 2 files
Processed: 2, failed: 0
bin-001.jpg image annotate
bin-002.jpg image annotate
```

{% hint style="success" %}
ऐप में प्रोजेक्ट खोलें। दोनों इमेज **Data** में हैं, और **Start Annotating** उन्हें **Item** क्लास के साथ खोलता है।
{% endhint %}

## क्या हुआ <a href="#what-happened" id="what-happened"></a>

| चरण | कॉल                          | नतीजा                                                                                                  |
| --- | ---------------------------- | ------------------------------------------------------------------------------------------------------ |
| 1   | `client.ontologies.create()` | एक क्लास और एक ज़रूरी प्रॉपर्टी वाली वर्कस्पेस ओन्टोलॉजी                                               |
| 2   | `client.projects.create()`   | उसी ओन्टोलॉजी से शुरू होने वाला प्रोजेक्ट                                                              |
| 3   | `project.upload()`           | फ़ाइलें समानांतर भेजी जाती हैं; Batch Queue ID और लोकल विफलताएँ लौटाता है                              |
| 4   | `batch.wait()`               | तब तक पोल करता है जब तक कुछ प्रोसेस न हो रहा हो; प्रोसेस हुए और फ़ेल हुए आइटम की गिनती लौटाता है       |
| 5   | `project.data_units()`       | हर फ़ाइल के लिए एक Data Unit, उसके वर्कफ़्लो स्टेटस के साथ (पहले स्टेज में इंतज़ार करते ही `annotate`) |

हर बार चलाने पर नई ओन्टोलॉजी और नया प्रोजेक्ट बनता है। किसी प्रोजेक्ट को दोबारा इस्तेमाल करने के लिए इसकी जगह `client.projects.get("PROJECT_ID")` कॉल करें।

## अगर कुछ गलत हो जाए <a href="#if-something-goes-wrong" id="if-something-goes-wrong"></a>

| लक्षण                                      | समाधान                                                                                    |
| ------------------------------------------ | ----------------------------------------------------------------------------------------- |
| `AuthenticationError: No API key provided` | `UNITLAB_API_KEY` सेट करें।                                                               |
| `PermissionDeniedError`                    | key के लिए **शुरू करने से पहले** में दी गई परमिशन चालू करें।                              |
| कोई फ़ाइल `batch.failed` में है            | `failure.error` पढ़ें, फ़ाइल ठीक करें और सिर्फ़ वही फ़ाइल दोबारा अपलोड करें।              |
| `status.failed` 0 से ज़्यादा है            | ऐप में Batch Queue खोलें, या `project.batch_queue(batch.batch_queue_id).data()` कॉल करें। |
| `ProcessingTimeoutError`                   | प्रोसेसिंग अभी चल रही है। बाद में `project.batch_queue(id).wait()` फिर से कॉल करें।       |

## अगले कदम <a href="#next-steps" id="next-steps"></a>

* [अपलोड, लेबल और एक्सपोर्ट](https://docs.unitlab.ai/api-sdk-cli/hi/get-started/upload-label-and-export.md): मॉडल लेबल इम्पोर्ट करें, रिव्यू करें और रिलीज़ एक्सपोर्ट करें।
* [प्रोजेक्ट अपलोड](https://docs.unitlab.ai/api-sdk-cli/hi/sdks/project-uploads.md): वीडियो फ़्रेम रेट, CSV, मेडिकल, टाइल्ड रास्टर और सीमाएँ।
* [Python में ओन्टोलॉजी बनाएँ](https://docs.unitlab.ai/api-sdk-cli/hi/sdks/build-ontologies-in-python.md): हर शेप और प्रॉपर्टी टाइप।

## संबंधित पेज <a href="#related" id="related"></a>

[CLI क्विकस्टार्ट](https://docs.unitlab.ai/api-sdk-cli/hi/get-started/cli-quickstart.md) · [UnitlabClient और रिसोर्स namespace](https://docs.unitlab.ai/api-sdk-cli/hi/sdks/unitlabclient-and-resource-namespaces.md) · [एक्सेप्शन, टाइमआउट और रीट्राई](https://docs.unitlab.ai/api-sdk-cli/hi/sdks/exceptions-timeouts-and-retries.md)
