Repository: voxel51/fiftyone

Issue:
[BUG] UnboundLocalError: local variable 'd' referenced before assignment
### Instructions



### System information

-   **Linux Ubuntu**
-   **FiftyOne installed from pip**
-   **FiftyOne v0.11.2**
-   **Python v3.8.5**

### Commands to reproduce

```
python app.py
```

### Describe the problem

I wrote app.py to load coco-2017 dataset and launch web app of fiftyone, but crash with Exception

### Code to reproduce issue

```
import fiftyone as fo
import fiftyone.zoo as foz

dataset = foz.load_zoo_dataset(
    "coco-2017",
    split="validation",
    dataset_name="evaluate-detections-tutorial",
)
dataset.persistent = True

session = fo.launch_app(dataset)

session.wait()
```

### Other info / logs

Log is:
Downloading split 'validation' to '/home/tommytao/fiftyone/coco-2017/validation' if necessary
Found annotations at '/home/tommytao/fiftyone/coco-2017/raw/instances_val2017.json'
Images already downloaded
Uncaught exception
Traceback (most recent call last):
  File "51app.py", line 4, in <module>
    dataset = foz.load_zoo_dataset(
  File "/home/tommytao/miniconda3/envs/ai/lib/python3.8/site-packages/fiftyone/zoo/datasets/__init__.py", line 195, in load_zoo_dataset
    info, dataset_dir = download_zoo_dataset(
  File "/home/tommytao/miniconda3/envs/ai/lib/python3.8/site-packages/fiftyone/zoo/datasets/__init__.py", line 116, in download_zoo_dataset
    return zoo_dataset.download_and_prepare(
  File "/home/tommytao/miniconda3/envs/ai/lib/python3.8/site-packages/fiftyone/zoo/datasets/__init__.py", line 1022, in download_and_prepare
    ) = self._download_and_prepare(split_dir, scratch_dir, split)
  File "/home/tommytao/miniconda3/envs/ai/lib/python3.8/site-packages/fiftyone/zoo/datasets/base.py", line 770, in _download_and_prepare
    num_samples, classes, downloaded = fouc.download_coco_dataset_split(
  File "/home/tommytao/miniconda3/envs/ai/lib/python3.8/site-packages/fiftyone/utils/coco.py", line 1617, in download_coco_dataset_split
    if d is None:
UnboundLocalError: local variable 'd' referenced before assignment

### What areas of FiftyOne does this bug affect?

-   [x] `App`: FiftyOne application issue
-   [ ] `Core`: Core `fiftyone` Python library issue
-   [ ] `Server`: Fiftyone server issue

### Willingness to contribute

The FiftyOne Community encourages bug fix contributions. Would you or another
member of your organization be willing to contribute a fix for this bug to the
FiftyOne codebase?

-   [ ] Yes. I can contribute a fix for this bug independently.
-   [x] Yes. I would be willing to contribute a fix for this bug with guidance
        from the FiftyOne community.
-   [ ] No. I cannot contribute a bug fix at this time.



Discussion:

Resolving patch:
diff --git a/fiftyone/utils/coco.py b/fiftyone/utils/coco.py
--- a/fiftyone/utils/coco.py
+++ b/fiftyone/utils/coco.py
@@ -1479,13 +1479,9 @@ def download_coco_dataset_split(
     else:
         logger.info("Found %s at '%s'", anno_type, full_anno_path)
 
-    (
-        _,
-        all_classes,
-        _,
-        images,
-        annotations,
-    ) = load_coco_detection_annotations(full_anno_path)
+    # This will store the loaded annotations, if they were necessary
+    d = None
+    all_classes = None
 
     #
     # Download images to `images_dir`, if necessary


Test patch:
diff --git a/tests/intensive/dataset_zoo_tests.py b/tests/intensive/dataset_zoo_tests.py
--- a/tests/intensive/dataset_zoo_tests.py
+++ b/tests/intensive/dataset_zoo_tests.py
@@ -205,6 +205,9 @@ def test_coco_2017():
     assert counts["person"] >= 25
     dataset.delete()
 
+    dataset = foz.load_zoo_dataset("coco-2017", split="validation")
+    dataset.delete()
+
 
 def test_open_images_v6():
     dataset = foz.load_zoo_dataset(