Comments (4)
@athn-nik With this method you can't write JSON file and you will get following error.
TypeError: Object of type ndarray is not JSON serializable
because JSON format is quite different and built-in json module can only handle primitives types that have a direct JSON equivalent (lists, dictionary, strings etc.) check following screenshot.
To get JSON file we need to serialize or encode NumPy array into JSON format.
As you know that json module has a JSONEncoder class, we can use this class to encode our NumPy array data into JSON format.
Here is example that how you can solve it.
class NumpyArrayEncode(JSONEncoder):
def default(self, o):
if isinstance(o, numpy.ndarray):
return o.tolist()
return JSONEncoder.default(self, o)
numpyArray = numpy.array(vibe_results)
#then to write data in JSON
json.dump(numpyArray, fp, cls=NumpyArrayEncode)
Note: Don't forget to import JSONEncoder from json module
from json import JSONEncoder
@lan786 try it. I hope it will solve your problem.
from vibe.
It is pretty easy do it yourself and the open a pull request and we can merge it.
Something like:
with open('vibe_results.json', 'w') as fp:
json.dump(vibe_results, fp)
should be enough. However json is not so memory efficient. Also ujson
package is more efficient than json in my experience.
from vibe.
@ahsan3803 Thanks so much for this solution. I faced same problem as you mention and now I have solved it with your provided example.
@athn-nik As I read code and data and it seems that ndarray is different in pkl. In ujson I'm unable to find that how we can encode numpy array as suggested in above solution. I'll submit a new issue in ujson repository.
from vibe.
Ok, I don't think a pull request is needed for this. If you want you can open one. I am closing this for now. Thanks for the solution @ahsan3803 . Happy to help with more issues @lan786
from vibe.
Related Issues (20)
- [BUG]About running too slow
- [BUG] loss will suddenly increase very high in the train process
- Converting weak perspective camera parameters to Blender camera projection models HOT 1
- [FEATURE]How to get an output video with a frame rate of 60fps?
- The requirements are too out-dated HOT 2
- COLAB not working HOT 1
- Code of checking that all joints are visible[BUG] HOT 1
- [FEATURE]dataset on the amass website is inconsistent with the dataset used for this project HOT 3
- [BUG] Bbox data error when preprocessing the posetrack dataset
- Number of body joints?
- Available Human3.6 processed file for Research? HOT 1
- [Clarification] What does `(sx,sy,tx,ty)` mean?
- [BUG] Fbx conversion script only giving out one person HOT 3
- [BUG]can anybody have AMASS dataset, I dowload many times but fialed every times.thanks.
- About coordinate system of 'joints3d'
- Unable to download BMLrub and CMU
- [BUG] How do I run VIBE on CPU? HOT 1
- [BUG] In fbx_output, why does quaternion rotation uses the `@` operator instead of the `*` operator? HOT 1
- : cannot connect to X server
- What is the axis in terms of which the SMPL pose parameters are defined?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vibe.