Classification
ClassificationModel
¶
Run inference on a classification model hosted on Roboflow or served through Roboflow Inference.
Source code in roboflow/models/classification.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
__exception_check(image_path_check=None)
¶
Check to see if an image exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_path_check |
str
|
path to the image to check |
None
|
Raises:
Type | Description |
---|---|
Exception
|
if image does not exist |
Source code in roboflow/models/classification.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
__generate_url()
¶
Generate a Roboflow API URL on which to run inference.
Returns:
Name | Type | Description |
---|---|---|
url |
str
|
the url on which to run inference |
Source code in roboflow/models/classification.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
__init__(api_key, id, name=None, version=None, local=False, colors=None, preprocessing=None)
¶
Create a ClassificationModel object through which you can run inference.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_key |
str
|
private roboflow api key |
required |
id |
str
|
the workspace/project id |
required |
name |
str
|
is the name of the project |
None
|
version |
int
|
version number |
None
|
local |
bool
|
whether the image is local or hosted |
False
|
colors |
dict
|
colors to use for the image |
None
|
preprocessing |
dict
|
preprocessing to use for the image |
None
|
Returns:
Type | Description |
---|---|
ClassificationModel Object |
Source code in roboflow/models/classification.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
__str__()
¶
String representation of classification object
Source code in roboflow/models/classification.py
167 168 169 170 171 172 173 174 175 176 177 |
|
load_model(name, version)
¶
Load a model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
is the name of the model you'd like to load |
required |
version |
int
|
version number |
required |
Source code in roboflow/models/classification.py
117 118 119 120 121 122 123 124 125 126 127 128 |
|
predict(image_path, hosted=False)
¶
Run inference on an image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_path |
str
|
path to the image you'd like to perform prediction on |
required |
hosted |
bool
|
whether the image you're providing is hosted on Roboflow |
False
|
Returns:
Type | Description |
---|---|
PredictionGroup Object |
Example
import roboflow
rf = roboflow.Roboflow(api_key="")
project = rf.workspace().project("PROJECT_ID")
model = project.version("1").model
prediction = model.predict("YOUR_IMAGE.jpg")
Source code in roboflow/models/classification.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|