Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
primordial-positron
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rob Kooper
primordial-positron
Commits
b2c1cdea
Commit
b2c1cdea
authored
1 year ago
by
Nattapon Jaroenchai
Browse files
Options
Downloads
Patches
Plain Diff
Update inference.py
parent
3245bd41
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inference.py
+8
-6
8 additions, 6 deletions
inference.py
with
8 additions
and
6 deletions
inference.py
+
8
−
6
View file @
b2c1cdea
...
...
@@ -3,6 +3,7 @@ import math
import
cv2
import
os
import
numpy
as
np
from
PIL
import
Image
import
rasterio
import
tensorflow
as
tf
from
keras.models
import
load_model
...
...
@@ -111,18 +112,19 @@ def save_results(prediction, outputPath, map_name, legend):
Save the prediction results to a specified output path.
Parameters:
- prediction: The prediction result.
- prediction: The prediction result
(should be a 2D or 3D numpy array)
.
- outputPath: The directory where the results should be saved.
- map_name: The name of the map.
- legend: The legend associated with the prediction.
"""
global
h5_image
output_image_path
=
os
.
path
.
join
(
outputPath
,
f
"
{
map_name
}
_
{
legend
}
.tif
"
)
# Save the prediction to the output path
with
open
(
output_image_path
,
'
w
'
)
as
f
:
f
.
write
(
str
(
prediction
))
# Convert the prediction to an image
# Note: The prediction array may need to be scaled or converted before saving as an image
prediction_image
=
Image
.
fromarray
(
prediction
.
astype
(
np
.
uint8
))
# Save the prediction as a tiff image
prediction_image
.
save
(
output_image_path
,
'
TIFF
'
)
### Waiting for georeferencing data
# This section will be used in future releases to save georeferenced images.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment