We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG] Support Fortran ordered masks in the App
Currently fortran ordered masks are flipped.

```py
import fiftyone as fo
import fiftyone.zoo as foz
import numpy as np

dataset = foz.load_zoo_dataset("quickstart", max_samples=1).select_fields().clone()
sample = dataset.first()

contiguous = np.asarray([[True, False], [True, False]])
sample["contiguous"] = fo.Segmentation(mask=contiguous)
sample["fortran"] = fo.Segmentation(mask=np.asfortranarray(contiguous))
sample.save()

session = fo.Session(dataset)
```
<img width="1792" alt="flipped" src="https://user-images.githubusercontent.com/19821840/159953546-5eef71bc-d111-4667-a271-6c4e34e1b7da.png">



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `fiftyone/server/json_util.py`
Content:
```
1 """
2 FiftyOne server json utilies.
3 
4 | Copyright 2017-2022, Voxel51, Inc.
5 | `voxel51.com <https://voxel51.com/>`_
6 |
7 """
8 from bson import ObjectId, json_util
9 from collections import OrderedDict
10 from datetime import date, datetime
11 from json import JSONEncoder
12 import math
13 
14 from fiftyone.core.sample import Sample, SampleView
15 from fiftyone.core.stages import ViewStage
16 import fiftyone.core.utils as fou
17 
18 
19 _MASK_CLASSES = {"Detection", "Heatmap", "Segmentation"}
20 
21 
22 def _handle_bytes(o):
23     for k, v in o.items():
24         if isinstance(v, bytes):
25             o[k] = str(fou.deserialize_numpy_array(v).shape)
26         elif isinstance(v, dict):
27             o[k] = _handle_bytes(v)
28 
29     return o
30 
31 
32 def _handle_numpy_array(raw, _cls=None):
33     if _cls not in _MASK_CLASSES:
34         return str(fou.deserialize_numpy_array(raw).shape)
35 
36     return fou.serialize_numpy_array(
37         fou.deserialize_numpy_array(raw), ascii=True
38     )
39 
40 
41 def _handle_date(dt):
42     return {
43         "_cls": "DateTime",
44         "datetime": fou.datetime_to_timestamp(dt),
45     }
46 
47 
48 def _is_invalid_number(value):
49     if not isinstance(value, float):
50         return False
51 
52     return math.isnan(value) or math.isinf(value)
53 
54 
55 def convert(d):
56     if isinstance(d, (dict, OrderedDict)):
57         for k, v in d.items():
58             if isinstance(v, bytes):
59                 d[k] = _handle_numpy_array(v, d.get("_cls", None))
60             elif isinstance(v, (date, datetime)):
61                 d[k] = _handle_date(v)
62             elif isinstance(v, ObjectId):
63                 d[k] = str(v)
64             elif isinstance(v, (dict, OrderedDict, list)):
65                 convert(v)
66             elif _is_invalid_number(v):
67                 d[k] = str(v)
68 
69     if isinstance(d, list):
70         for idx, i in enumerate(d):
71             if isinstance(i, tuple):
72                 d[idx] = list(i)
73                 i = d[idx]
74 
75             if isinstance(i, bytes):
76                 d[idx] = _handle_numpy_array(i)
77             elif isinstance(i, (date, datetime)):
78                 d[idx] = _handle_date(i)
79             elif isinstance(i, ObjectId):
80                 d[idx] = str(i)
81             elif isinstance(i, (dict, OrderedDict, list)):
82                 convert(i)
83             elif _is_invalid_number(i):
84                 d[idx] = str(i)
85 
86 
87 class FiftyOneJSONEncoder(JSONEncoder):
88     """JSON encoder for the FiftyOne server.
89 
90     Any classes with non-standard serialization methods should
91     be accounted for in the `default()` method.
92     """
93 
94     def default(self, o):  # pylint: disable=E0202
95         """Returns the serialized representation of the objects
96 
97         Args:
98             o: the object
99 
100         Returns:
101             str
102         """
103         if isinstance(o, (Sample, SampleView)):
104             return _handle_bytes(o.to_mongo_dict(include_id=True))
105         if issubclass(type(o), ViewStage):
106             return o._serialize()
107         if isinstance(o, ObjectId):
108             return str(o)
109         if isinstance(o, float):
110             return json_util.dumps(o)
111         return super().default(o)
112 
113     @staticmethod
114     def dumps(*args, **kwargs):
115         """Defined for overriding the default SocketIO `json` interface"""
116         kwargs["cls"] = FiftyOneJSONEncoder
117         return json_util.dumps(
118             json_util.loads(
119                 json_util.dumps(*args, **kwargs), parse_constant=lambda c: c
120             ),
121             **kwargs
122         )
123 
124     @staticmethod
125     def loads(*args, **kwargs):
126         """Defined for overriding the default SocketIO `json` interface"""
127         return json_util.loads(*args, **kwargs)
128
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/fiftyone/server/json_util.py b/fiftyone/server/json_util.py
--- a/fiftyone/server/json_util.py
+++ b/fiftyone/server/json_util.py
@@ -10,6 +10,7 @@
 from datetime import date, datetime
 from json import JSONEncoder
 import math
+import numpy as np
 
 from fiftyone.core.sample import Sample, SampleView
 from fiftyone.core.stages import ViewStage
@@ -33,9 +34,12 @@
     if _cls not in _MASK_CLASSES:
         return str(fou.deserialize_numpy_array(raw).shape)
 
-    return fou.serialize_numpy_array(
-        fou.deserialize_numpy_array(raw), ascii=True
-    )
+    array = fou.deserialize_numpy_array(raw)
+
+    if np.isfortran(array):
+        array = np.ascontiguousarray(array)
+
+    return fou.serialize_numpy_array(array, ascii=True)
 
 
 def _handle_date(dt):

{"golden_diff": "diff --git a/fiftyone/server/json_util.py b/fiftyone/server/json_util.py\n--- a/fiftyone/server/json_util.py\n+++ b/fiftyone/server/json_util.py\n@@ -10,6 +10,7 @@\n from datetime import date, datetime\n from json import JSONEncoder\n import math\n+import numpy as np\n \n from fiftyone.core.sample import Sample, SampleView\n from fiftyone.core.stages import ViewStage\n@@ -33,9 +34,12 @@\n     if _cls not in _MASK_CLASSES:\n         return str(fou.deserialize_numpy_array(raw).shape)\n \n-    return fou.serialize_numpy_array(\n-        fou.deserialize_numpy_array(raw), ascii=True\n-    )\n+    array = fou.deserialize_numpy_array(raw)\n+\n+    if np.isfortran(array):\n+        array = np.ascontiguousarray(array)\n+\n+    return fou.serialize_numpy_array(array, ascii=True)\n \n \n def _handle_date(dt):\n", "issue": "[BUG] Support Fortran ordered masks in the App\nCurrently fortran ordered masks are flipped.\r\n\r\n```py\r\nimport fiftyone as fo\r\nimport fiftyone.zoo as foz\r\nimport numpy as np\r\n\r\ndataset = foz.load_zoo_dataset(\"quickstart\", max_samples=1).select_fields().clone()\r\nsample = dataset.first()\r\n\r\ncontiguous = np.asarray([[True, False], [True, False]])\r\nsample[\"contiguous\"] = fo.Segmentation(mask=contiguous)\r\nsample[\"fortran\"] = fo.Segmentation(mask=np.asfortranarray(contiguous))\r\nsample.save()\r\n\r\nsession = fo.Session(dataset)\r\n```\r\n<img width=\"1792\" alt=\"flipped\" src=\"https://user-images.githubusercontent.com/19821840/159953546-5eef71bc-d111-4667-a271-6c4e34e1b7da.png\">\r\n\r\n\n", "before_files": [{"content": "\"\"\"\nFiftyOne server json utilies.\n\n| Copyright 2017-2022, Voxel51, Inc.\n| `voxel51.com <https://voxel51.com/>`_\n|\n\"\"\"\nfrom bson import ObjectId, json_util\nfrom collections import OrderedDict\nfrom datetime import date, datetime\nfrom json import JSONEncoder\nimport math\n\nfrom fiftyone.core.sample import Sample, SampleView\nfrom fiftyone.core.stages import ViewStage\nimport fiftyone.core.utils as fou\n\n\n_MASK_CLASSES = {\"Detection\", \"Heatmap\", \"Segmentation\"}\n\n\ndef _handle_bytes(o):\n    for k, v in o.items():\n        if isinstance(v, bytes):\n            o[k] = str(fou.deserialize_numpy_array(v).shape)\n        elif isinstance(v, dict):\n            o[k] = _handle_bytes(v)\n\n    return o\n\n\ndef _handle_numpy_array(raw, _cls=None):\n    if _cls not in _MASK_CLASSES:\n        return str(fou.deserialize_numpy_array(raw).shape)\n\n    return fou.serialize_numpy_array(\n        fou.deserialize_numpy_array(raw), ascii=True\n    )\n\n\ndef _handle_date(dt):\n    return {\n        \"_cls\": \"DateTime\",\n        \"datetime\": fou.datetime_to_timestamp(dt),\n    }\n\n\ndef _is_invalid_number(value):\n    if not isinstance(value, float):\n        return False\n\n    return math.isnan(value) or math.isinf(value)\n\n\ndef convert(d):\n    if isinstance(d, (dict, OrderedDict)):\n        for k, v in d.items():\n            if isinstance(v, bytes):\n                d[k] = _handle_numpy_array(v, d.get(\"_cls\", None))\n            elif isinstance(v, (date, datetime)):\n                d[k] = _handle_date(v)\n            elif isinstance(v, ObjectId):\n                d[k] = str(v)\n            elif isinstance(v, (dict, OrderedDict, list)):\n                convert(v)\n            elif _is_invalid_number(v):\n                d[k] = str(v)\n\n    if isinstance(d, list):\n        for idx, i in enumerate(d):\n            if isinstance(i, tuple):\n                d[idx] = list(i)\n                i = d[idx]\n\n            if isinstance(i, bytes):\n                d[idx] = _handle_numpy_array(i)\n            elif isinstance(i, (date, datetime)):\n                d[idx] = _handle_date(i)\n            elif isinstance(i, ObjectId):\n                d[idx] = str(i)\n            elif isinstance(i, (dict, OrderedDict, list)):\n                convert(i)\n            elif _is_invalid_number(i):\n                d[idx] = str(i)\n\n\nclass FiftyOneJSONEncoder(JSONEncoder):\n    \"\"\"JSON encoder for the FiftyOne server.\n\n    Any classes with non-standard serialization methods should\n    be accounted for in the `default()` method.\n    \"\"\"\n\n    def default(self, o):  # pylint: disable=E0202\n        \"\"\"Returns the serialized representation of the objects\n\n        Args:\n            o: the object\n\n        Returns:\n            str\n        \"\"\"\n        if isinstance(o, (Sample, SampleView)):\n            return _handle_bytes(o.to_mongo_dict(include_id=True))\n        if issubclass(type(o), ViewStage):\n            return o._serialize()\n        if isinstance(o, ObjectId):\n            return str(o)\n        if isinstance(o, float):\n            return json_util.dumps(o)\n        return super().default(o)\n\n    @staticmethod\n    def dumps(*args, **kwargs):\n        \"\"\"Defined for overriding the default SocketIO `json` interface\"\"\"\n        kwargs[\"cls\"] = FiftyOneJSONEncoder\n        return json_util.dumps(\n            json_util.loads(\n                json_util.dumps(*args, **kwargs), parse_constant=lambda c: c\n            ),\n            **kwargs\n        )\n\n    @staticmethod\n    def loads(*args, **kwargs):\n        \"\"\"Defined for overriding the default SocketIO `json` interface\"\"\"\n        return json_util.loads(*args, **kwargs)\n", "path": "fiftyone/server/json_util.py"}], "after_files": [{"content": "\"\"\"\nFiftyOne server json utilies.\n\n| Copyright 2017-2022, Voxel51, Inc.\n| `voxel51.com <https://voxel51.com/>`_\n|\n\"\"\"\nfrom bson import ObjectId, json_util\nfrom collections import OrderedDict\nfrom datetime import date, datetime\nfrom json import JSONEncoder\nimport math\nimport numpy as np\n\nfrom fiftyone.core.sample import Sample, SampleView\nfrom fiftyone.core.stages import ViewStage\nimport fiftyone.core.utils as fou\n\n\n_MASK_CLASSES = {\"Detection\", \"Heatmap\", \"Segmentation\"}\n\n\ndef _handle_bytes(o):\n    for k, v in o.items():\n        if isinstance(v, bytes):\n            o[k] = str(fou.deserialize_numpy_array(v).shape)\n        elif isinstance(v, dict):\n            o[k] = _handle_bytes(v)\n\n    return o\n\n\ndef _handle_numpy_array(raw, _cls=None):\n    if _cls not in _MASK_CLASSES:\n        return str(fou.deserialize_numpy_array(raw).shape)\n\n    array = fou.deserialize_numpy_array(raw)\n\n    if np.isfortran(array):\n        array = np.ascontiguousarray(array)\n\n    return fou.serialize_numpy_array(array, ascii=True)\n\n\ndef _handle_date(dt):\n    return {\n        \"_cls\": \"DateTime\",\n        \"datetime\": fou.datetime_to_timestamp(dt),\n    }\n\n\ndef _is_invalid_number(value):\n    if not isinstance(value, float):\n        return False\n\n    return math.isnan(value) or math.isinf(value)\n\n\ndef convert(d):\n    if isinstance(d, (dict, OrderedDict)):\n        for k, v in d.items():\n            if isinstance(v, bytes):\n                d[k] = _handle_numpy_array(v, d.get(\"_cls\", None))\n            elif isinstance(v, (date, datetime)):\n                d[k] = _handle_date(v)\n            elif isinstance(v, ObjectId):\n                d[k] = str(v)\n            elif isinstance(v, (dict, OrderedDict, list)):\n                convert(v)\n            elif _is_invalid_number(v):\n                d[k] = str(v)\n\n    if isinstance(d, list):\n        for idx, i in enumerate(d):\n            if isinstance(i, tuple):\n                d[idx] = list(i)\n                i = d[idx]\n\n            if isinstance(i, bytes):\n                d[idx] = _handle_numpy_array(i)\n            elif isinstance(i, (date, datetime)):\n                d[idx] = _handle_date(i)\n            elif isinstance(i, ObjectId):\n                d[idx] = str(i)\n            elif isinstance(i, (dict, OrderedDict, list)):\n                convert(i)\n            elif _is_invalid_number(i):\n                d[idx] = str(i)\n\n\nclass FiftyOneJSONEncoder(JSONEncoder):\n    \"\"\"JSON encoder for the FiftyOne server.\n\n    Any classes with non-standard serialization methods should\n    be accounted for in the `default()` method.\n    \"\"\"\n\n    def default(self, o):  # pylint: disable=E0202\n        \"\"\"Returns the serialized representation of the objects\n\n        Args:\n            o: the object\n\n        Returns:\n            str\n        \"\"\"\n        if isinstance(o, (Sample, SampleView)):\n            return _handle_bytes(o.to_mongo_dict(include_id=True))\n        if issubclass(type(o), ViewStage):\n            return o._serialize()\n        if isinstance(o, ObjectId):\n            return str(o)\n        if isinstance(o, float):\n            return json_util.dumps(o)\n        return super().default(o)\n\n    @staticmethod\n    def dumps(*args, **kwargs):\n        \"\"\"Defined for overriding the default SocketIO `json` interface\"\"\"\n        kwargs[\"cls\"] = FiftyOneJSONEncoder\n        return json_util.dumps(\n            json_util.loads(\n                json_util.dumps(*args, **kwargs), parse_constant=lambda c: c\n            ),\n            **kwargs\n        )\n\n    @staticmethod\n    def loads(*args, **kwargs):\n        \"\"\"Defined for overriding the default SocketIO `json` interface\"\"\"\n        return json_util.loads(*args, **kwargs)\n", "path": "fiftyone/server/json_util.py"}]}