Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
c6d778ea
Commit
c6d778ea
authored
May 09, 2014
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made the examples use the new simplified file serialization API.
parent
eb2806f3
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
31 additions
and
80 deletions
+31
-80
assignment_learning_ex.cpp
examples/assignment_learning_ex.cpp
+2
-5
custom_trainer_ex.cpp
examples/custom_trainer_ex.cpp
+3
-6
fhog_object_detector_ex.cpp
examples/fhog_object_detector_ex.cpp
+2
-5
krls_ex.cpp
examples/krls_ex.cpp
+3
-7
krr_classification_ex.cpp
examples/krr_classification_ex.cpp
+2
-6
krr_regression_ex.cpp
examples/krr_regression_ex.cpp
+2
-6
learning_to_track_ex.cpp
examples/learning_to_track_ex.cpp
+2
-5
multiclass_classification_ex.cpp
examples/multiclass_classification_ex.cpp
+2
-5
object_detector_ex.cpp
examples/object_detector_ex.cpp
+2
-5
rvm_ex.cpp
examples/rvm_ex.cpp
+2
-6
rvm_regression_ex.cpp
examples/rvm_regression_ex.cpp
+2
-6
sequence_labeler_ex.cpp
examples/sequence_labeler_ex.cpp
+2
-5
sequence_segmenter_ex.cpp
examples/sequence_segmenter_ex.cpp
+2
-5
svm_ex.cpp
examples/svm_ex.cpp
+2
-5
train_object_detector.cpp
examples/train_object_detector.cpp
+1
-3
No files found.
examples/assignment_learning_ex.cpp
View file @
c6d778ea
...
...
@@ -195,13 +195,10 @@ int main()
// Finally, the assigner can be serialized to disk just like most dlib objects.
ofstream
fout
(
"assigner.dat"
,
ios
::
binary
);
serialize
(
assigner
,
fout
);
fout
.
close
();
serialize
(
"assigner.dat"
)
<<
assigner
;
// recall from disk
ifstream
fin
(
"assigner.dat"
,
ios
::
binary
);
deserialize
(
assigner
,
fin
);
deserialize
(
"assigner.dat"
)
>>
assigner
;
}
catch
(
std
::
exception
&
e
)
{
...
...
examples/custom_trainer_ex.cpp
View file @
c6d778ea
...
...
@@ -208,15 +208,12 @@ int main()
decision_function
<
radial_basis_kernel
<
sample_type
>
>
// This is the output of the rbf_trainer
>
df2
,
df3
;
df2
=
df
;
ofstream
fout
(
"df.dat"
,
ios
::
binary
);
serialize
(
df2
,
fout
);
fout
.
close
();
// save to a file called df.dat
serialize
(
"df.dat"
)
<<
df2
;
// load the function back in from disk and store it in df3.
ifstream
fin
(
"df.dat"
,
ios
::
binary
);
deserialize
(
df3
,
fin
);
deserialize
(
"df.dat"
)
>>
df3
;
// Test df3 to see that this worked.
...
...
examples/fhog_object_detector_ex.cpp
View file @
c6d778ea
...
...
@@ -180,14 +180,11 @@ int main(int argc, char** argv)
// Like everything in dlib, you can save your detector to disk using the
// serialize() function.
ofstream
fout
(
"face_detector.svm"
,
ios
::
binary
);
serialize
(
detector
,
fout
);
fout
.
close
();
serialize
(
"face_detector.svm"
)
<<
detector
;
// Then you can recall it using the deserialize() function.
ifstream
fin
(
"face_detector.svm"
,
ios
::
binary
);
object_detector
<
image_scanner_type
>
detector2
;
deserialize
(
detector2
,
fin
)
;
deserialize
(
"face_detector.svm"
)
>>
detector2
;
...
...
examples/krls_ex.cpp
View file @
c6d778ea
...
...
@@ -78,21 +78,17 @@ int main()
// Another thing that is worth knowing is that just about everything in dlib is serializable.
// So for example, you can save the test object to disk and recall it later like so:
ofstream
fout
(
"saved_krls_object.dat"
,
ios
::
binary
);
serialize
(
test
,
fout
);
fout
.
close
();
serialize
(
"saved_krls_object.dat"
)
<<
test
;
// Now let's open that file back up and load the krls object it contains.
ifstream
fin
(
"saved_krls_object.dat"
,
ios
::
binary
);
deserialize
(
test
,
fin
);
deserialize
(
"saved_krls_object.dat"
)
>>
test
;
// If you don't want to save the whole krls object (it might be a bit large)
// you can save just the decision function it has learned so far. You can get
// the decision function out of it by calling test.get_decision_function() and
// then you can serialize that object instead. E.g.
decision_function
<
kernel_type
>
funct
=
test
.
get_decision_function
();
fout
.
open
(
"saved_krls_function.dat"
,
ios
::
binary
);
serialize
(
funct
,
fout
);
serialize
(
"saved_krls_function.dat"
)
<<
funct
;
}
examples/krr_classification_ex.cpp
View file @
c6d778ea
...
...
@@ -196,14 +196,10 @@ int main()
// Another thing that is worth knowing is that just about everything in dlib is serializable.
// So for example, you can save the learned_pfunct object to disk and recall it later like so:
ofstream
fout
(
"saved_function.dat"
,
ios
::
binary
);
serialize
(
learned_pfunct
,
fout
);
fout
.
close
();
serialize
(
"saved_function.dat"
)
<<
learned_pfunct
;
// Now let's open that file back up and load the function object it contains.
ifstream
fin
(
"saved_function.dat"
,
ios
::
binary
);
deserialize
(
learned_pfunct
,
fin
);
deserialize
(
"saved_function.dat"
)
>>
learned_pfunct
;
}
examples/krr_regression_ex.cpp
View file @
c6d778ea
...
...
@@ -94,14 +94,10 @@ int main()
// Another thing that is worth knowing is that just about everything in dlib is serializable.
// So for example, you can save the test object to disk and recall it later like so:
ofstream
fout
(
"saved_function.dat"
,
ios
::
binary
);
serialize
(
test
,
fout
);
fout
.
close
();
serialize
(
"saved_function.dat"
)
<<
test
;
// Now let's open that file back up and load the function object it contains.
ifstream
fin
(
"saved_function.dat"
,
ios
::
binary
);
deserialize
(
test
,
fin
);
deserialize
(
"saved_function.dat"
)
>>
test
;
}
...
...
examples/learning_to_track_ex.cpp
View file @
c6d778ea
...
...
@@ -344,13 +344,10 @@ int main()
// Finally, you can save your track_association_function to disk like so:
ofstream
fout
(
"track_assoc.svm"
,
ios
::
binary
);
serialize
(
assoc
,
fout
);
fout
.
close
();
serialize
(
"track_assoc.svm"
)
<<
assoc
;
// And recall it from disk later like so:
ifstream
fin
(
"track_assoc.svm"
,
ios
::
binary
);
deserialize
(
assoc
,
fin
);
deserialize
(
"track_assoc.svm"
)
>>
assoc
;
}
// ----------------------------------------------------------------------------------------
...
...
examples/multiclass_classification_ex.cpp
View file @
c6d778ea
...
...
@@ -138,13 +138,10 @@ int main()
// Put df into df2 and then save df2 to disk. Note that we could have also said
// df2 = trainer.train(samples, labels); But doing it this way avoids retraining.
df2
=
df
;
ofstream
fout
(
"df.dat"
,
ios
::
binary
);
serialize
(
df2
,
fout
);
fout
.
close
();
serialize
(
"df.dat"
)
<<
df2
;
// load the function back in from disk and store it in df3.
ifstream
fin
(
"df.dat"
,
ios
::
binary
);
deserialize
(
df3
,
fin
);
deserialize
(
"df.dat"
)
>>
df3
;
// Test df3 to see that this worked.
...
...
examples/object_detector_ex.cpp
View file @
c6d778ea
...
...
@@ -247,13 +247,10 @@ int main()
// Finally, note that the detector can be serialized to disk just like other dlib objects.
ofstream
fout
(
"object_detector.dat"
,
ios
::
binary
);
serialize
(
detector
,
fout
);
fout
.
close
();
serialize
(
"object_detector.dat"
)
<<
detector
;
// Recall from disk.
ifstream
fin
(
"object_detector.dat"
,
ios
::
binary
);
deserialize
(
detector
,
fin
);
deserialize
(
"object_detector.dat"
)
>>
detector
;
}
catch
(
exception
&
e
)
{
...
...
examples/rvm_ex.cpp
View file @
c6d778ea
...
...
@@ -208,14 +208,10 @@ int main()
// Another thing that is worth knowing is that just about everything in dlib is serializable.
// So for example, you can save the learned_pfunct object to disk and recall it later like so:
ofstream
fout
(
"saved_function.dat"
,
ios
::
binary
);
serialize
(
learned_pfunct
,
fout
);
fout
.
close
();
serialize
(
"saved_function.dat"
)
<<
learned_pfunct
;
// Now let's open that file back up and load the function object it contains.
ifstream
fin
(
"saved_function.dat"
,
ios
::
binary
);
deserialize
(
learned_pfunct
,
fin
);
deserialize
(
"saved_function.dat"
)
>>
learned_pfunct
;
}
examples/rvm_regression_ex.cpp
View file @
c6d778ea
...
...
@@ -91,14 +91,10 @@ int main()
// Another thing that is worth knowing is that just about everything in dlib is serializable.
// So for example, you can save the test object to disk and recall it later like so:
ofstream
fout
(
"saved_function.dat"
,
ios
::
binary
);
serialize
(
test
,
fout
);
fout
.
close
();
serialize
(
"saved_function.dat"
)
<<
test
;
// Now let's open that file back up and load the function object it contains.
ifstream
fin
(
"saved_function.dat"
,
ios
::
binary
);
deserialize
(
test
,
fin
);
deserialize
(
"saved_function.dat"
)
>>
test
;
}
...
...
examples/sequence_labeler_ex.cpp
View file @
c6d778ea
...
...
@@ -292,13 +292,10 @@ int main()
// Finally, the labeler can be serialized to disk just like most dlib objects.
ofstream
fout
(
"labeler.dat"
,
ios
::
binary
);
serialize
(
labeler
,
fout
);
fout
.
close
();
serialize
(
"labeler.dat"
)
<<
labeler
;
// recall from disk
ifstream
fin
(
"labeler.dat"
,
ios
::
binary
);
deserialize
(
labeler
,
fin
);
deserialize
(
"labeler.dat"
)
>>
labeler
;
}
// ----------------------------------------------------------------------------------------
...
...
examples/sequence_segmenter_ex.cpp
View file @
c6d778ea
...
...
@@ -228,13 +228,10 @@ int main()
// Finally, the segmenter can be serialized to disk just like most dlib objects.
ofstream
fout
(
"segmenter.dat"
,
ios
::
binary
);
serialize
(
segmenter
,
fout
);
fout
.
close
();
serialize
(
"segmenter.dat"
)
<<
segmenter
;
// recall from disk
ifstream
fin
(
"segmenter.dat"
,
ios
::
binary
);
deserialize
(
segmenter
,
fin
);
deserialize
(
"segmenter.dat"
)
>>
segmenter
;
}
// ----------------------------------------------------------------------------------------
...
...
examples/svm_ex.cpp
View file @
c6d778ea
...
...
@@ -210,13 +210,10 @@ int main()
// Another thing that is worth knowing is that just about everything in dlib is
// serializable. So for example, you can save the learned_pfunct object to disk and
// recall it later like so:
ofstream
fout
(
"saved_function.dat"
,
ios
::
binary
);
serialize
(
learned_pfunct
,
fout
);
fout
.
close
();
serialize
(
"saved_function.dat"
)
<<
learned_pfunct
;
// Now let's open that file back up and load the function object it contains.
ifstream
fin
(
"saved_function.dat"
,
ios
::
binary
);
deserialize
(
learned_pfunct
,
fin
);
deserialize
(
"saved_function.dat"
)
>>
learned_pfunct
;
// Note that there is also an example program that comes with dlib called the
// file_to_code_ex.cpp example. It is a simple program that takes a file and outputs a
...
...
examples/train_object_detector.cpp
View file @
c6d778ea
...
...
@@ -291,9 +291,7 @@ int main(int argc, char** argv)
object_detector
<
image_scanner_type
>
detector
=
trainer
.
train
(
images
,
object_locations
,
ignore
);
cout
<<
"Saving trained detector to object_detector.svm"
<<
endl
;
ofstream
fout
(
"object_detector.svm"
,
ios
::
binary
);
serialize
(
detector
,
fout
);
fout
.
close
();
serialize
(
"object_detector.svm"
)
<<
detector
;
cout
<<
"Testing detector on training data..."
<<
endl
;
cout
<<
"Test detector (precision,recall,AP): "
<<
test_object_detection_function
(
detector
,
images
,
object_locations
)
<<
endl
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment