{"id":27430998,"url":"https://github.com/bigmlcom/sensenet","last_synced_at":"2026-03-11T10:32:14.883Z","repository":{"id":40327717,"uuid":"271176987","full_name":"bigmlcom/sensenet","owner":"bigmlcom","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-02T20:58:22.000Z","size":98601,"stargazers_count":0,"open_issues_count":2,"forks_count":8,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-14T15:51:30.115Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bigmlcom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-06-10T04:15:54.000Z","updated_at":"2024-10-02T20:56:45.000Z","dependencies_parsed_at":"2025-04-14T15:48:04.802Z","dependency_job_id":null,"html_url":"https://github.com/bigmlcom/sensenet","commit_stats":null,"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"purl":"pkg:github/bigmlcom/sensenet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigmlcom%2Fsensenet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigmlcom%2Fsensenet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigmlcom%2Fsensenet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigmlcom%2Fsensenet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bigmlcom","download_url":"https://codeload.github.com/bigmlcom/sensenet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigmlcom%2Fsensenet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30378084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T06:09:32.197Z","status":"ssl_error","status_checked_at":"2026-03-11T06:09:17.086Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-14T15:28:15.296Z","updated_at":"2026-03-11T10:32:14.849Z","avatar_url":"https://github.com/bigmlcom.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BigML Sense/Net\n\nSense/Net is a BigML interface to Tensorflow, which takes a network\nspecification as a dictionary (read from BigML's JSON model format)\nand instantiates a TensorFlow compute graph based on that\nspecification.\n\n## Entry Points\n\nThe library is meant, in general, to take a BigML model specification\nas a JSON document, and an optional map of settings and return a\nlightweight wrapper around a `tf.keras.Model` based on these\narguments.  The wrapper creation function can be found in\n`sensenet.models.wrappers.create_model`\n\n## Pretrained Networks\n\nOften, BigML trained deepnets will use networks pretrained on\n[ImageNet](http://www.image-net.org/) either as a starting point for\nfine tuning, or as the base layers under a custom set of readout\nlayers.  The weights for these networks are stored in a public s3\nbucket and downloaded as needed for training or inference (see the\n`sensenet.pretrained` module).  If the pretrained weights are never\nneeded, no downloading occurs.\n\nBy default, these are downloaded to and read from the directory\n`~/.bigml_sensenet` (which is created if it is not present).  To\nchange the location of this directory, clients can set the environment\nvariable `BIGML_SENSENET_CACHE_PATH`.\n\n## Model Instantiation\n\nTo instantiate a model, pass the model specification and the dict of\nadditional, optional settings to `models.wrappers.create_model`.  For\nexample:\n\n```\nmodel = wrappers.create_model(a_dict, settings={'image_path_prefix': 'images/path/'})\n```\n\nAgain, `a_dict` is typically a downloaded BigML model, read into a\npython dictionary via `json.load` or similar.  You may also pass the\npath to a file containing such a model:\n\n```\nmodel = wrappers.create_model('model.json', settings=None)\n```\n\nA similar function, `models.wrappers.create_image_feature_extractor`,\nallows clients to create a model object that returns instead the\noutputs of the final global pooling or flattening layer of the image\nmodel, given an image as input:\n\n```\nextractor = create_image_feature_extractor(\"resnet18\", None)\nextractor(\"path/to/image.jpeg\").shape # (1, 512)\n```\n\nNote that this only works for networks with at least one image input,\nand does not work for bounding box models, as there is no global\npooling or flattening step in those models.\n\nFor both `create_image_feature_extractor` and `create model`,\n`settings` can either be `None` (the default) or a dict of optional\nsettings which may contain any of the settings arguments listed below.\n\n### Settings Arguments\n\nThese arguments can be passed to\n`models.wrappers.create_image_feature_extractor` or\n`models.wrappers.create_model` to change the input or output behavior\nof the model.  Note that the settings specific to bounding box models\nare ignored if the model is not of the bounding box type.\n\n- `bounding_box_threshold`: For object detection models only, the\n  minimal score that an object can have and still be surfaced to the\n  user as part of the output.  The default is 0.5, and lower the score\n  will have the effect of more (possibly spurious) boxes identified in\n  each input image.\n\n- `color_space`: A string which is one of `['rgb', 'rgba', 'bgr',\n  'bgra']`.  The first three letters give the order of the color\n  channels (red, blue, and green) in the input tensors that will be\n  passed to the model.  The final presence or absence of an `'a'`\n  indicates that an alpha channel will be present (which will be\n  ignored).  This can be useful to match the color space of the output\n  model to that provided by another library, such as open CV.  Note\n  that TensorFlow uses RGB ordering by default, and all files read by\n  TensorFlow are automatically read as RGB files.  This argument is\n  generally only necessary if `input_image_format` is\n  `'pixel_values'`, and will possibly break predictions if specified\n  when the input is a file.\n\n- `iou_threshold`: A threshold indicating the amount of overlap boxes\n  predicting the same class should have before they are considered to\n  be bounding the same object.  The default is 0.5, and lower values\n  have the effect of eliminating boxes which would otherwise have been\n  surfaced to the user.\n\n- `max_objects`: The maximum number of bounding boxes to return for\n  each image in bounding box models.  The default is 32.\n\n- `rescale_type`: A string which is one of `['warp', 'pad', 'crop']`.\n  If `'warp'`, input images are scaled to the input dimensions\n  specified in the network, and their aspect ratios are *not*\n  preserved.  If `'pad'`, the image is resized to the smallest\n  dimensions such that the image fits into the input dimensions of the\n  network, then padded with constant pixels either below or to the\n  right to create an appropriately sized image.  For example, if the\n  input dimensions of the network are 100 x 100, and we attempt to\n  classify a 300 x 600 image, the image is first rescaled to 50 x 100\n  (preserving its aspect ratio) then padded on the right to create a\n  100 x 100 image.  If `'crop'`, the image is resized to the smallest\n  dimension such that the input dimensions fit in the image, then the\n  image is centrally cropped to make the specified sizes.  Using the\n  sizes in previous example, the image would be rescaled to 100 x 200\n  (preserving its aspect ratio) then cropped by 50 pixels on the top\n  and bottom to create a 100 x 100 image.\n\nWhile these are not the only settings possible, these are the ones\nmost likely to be useful to clients; other settings are typically only\nuseful for very specific client applications.\n\n### Model Formats and Conversion\n\nThe canonical format for sensenet models is the JSON format\ndownloadable from BigML.  However, as the JSON is fairly heavyweight,\ntime-consuming to parse, and not consumable from certain locations,\nSenseNet offers a conversion utility,\n`sensenet.models.wrappers.convert`, which takes the JSON format as\ninput and can output the following formats:\n\n- `tflite` will export the model in the Tensorflow lite format, which\n  allows lightweight prediction on mobile devices.\n\n- `tfjs` exports the model to the format read by Tensorflow JS to do\n  predictions in the browser and server-side in node.js. The library\n  needed to do this export, `tensorflowjs`, is not available in all\n  architectures, so this feature may not always work.\n\n- `smbundle` exports the model to a (proprietary) lightweight wrapper\n  around the TensorFlow SavedModel format.  The generated file is a\n  concatenation of the files in the SavedModel directory, with some\n  additional information written to the `assets` sub-directory.  If\n  this file is passed to `create_model`, the bundle is extracted to a\n  temporary directory, the model instantiated, and the temporary files\n  deleted.  To extract the bundle without instantiating the model, see\n  the functions in `sensenet.models.bundle`.\n\n- `h5` exports the model **weights only** to the Keras h5 model format\n  (i.e., via use of the TensorFlow function\n  `tf.keras.Model.save_weights`) To use these, you'd instantiate the\n  model from JSON and load the weights separately using the\n  corresponding TensorFlow `load_weights` function.\n\n## Usage\n\nOnce instantiated, you can use the model to make predictions by using\nthe returned model as a function, like so:\n\n```\nprediction = model([1.0, 2.0, 3.0])\n```\n\nThe input point or points must be a list (or nested list) containing\nthe input data for each point, in the order implied by\n`model._preprocessors`.  Categorical and image variables should be\npassed as strings, where the image is either a path to the image on\ndisk, or the raw compressed image bytes.\n\nFor classification or regression models, the function returns a numpy\narray where each row is the model's prediction for each input point.\nFor classification models, there will be a probability for each class\nin each row.  For regression models, each row will contain only a\nsingle entry.\n\nFor object detection models, the input should always be a single image\n(again, either as a file path, compressed byte string, or an array of\npixel values, depending on the settings map, and the result will be\nlist of detected boxes, each one represented as a dictionary.  For\nexample:\n\n```\nIn [5]: model('pizza_people.jpg')\nOut[5]:\n[{'box': [16, 317, 283, 414], 'label': 'pizza', 'score': 0.9726969599723816},\n {'box': [323, 274, 414, 332], 'label': 'pizza', 'score': 0.7364346981048584},\n {'box': [158, 29, 400, 327], 'label': 'person', 'score': 0.6204285025596619},\n {'box': [15, 34, 283, 336], 'label': 'person', 'score': 0.5346986055374146},\n {'box': [311, 23, 416, 255], 'label': 'person', 'score': 0.41961848735809326}]\n```\n\nThe `box` array contains the coordinates of the detected box, as `x1,\ny1, x2, y2`, where those coordinates represent the upper-left and\nlower-right corners of each bounding box, in a coordinate system with\n(0, 0) at the upper-left of the input image.  The `score` is the rough\nprobability that the object has been correctly identified, and the\n`label` is the detected class of the object.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigmlcom%2Fsensenet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigmlcom%2Fsensenet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigmlcom%2Fsensenet/lists"}