Giter Club home page Giter Club logo

npz_json_converter's Introduction

Hi there ๐Ÿ‘‹

I'm Sharon and I'm a Software Developer

  • I'm currently developing research applications using Python for the USGS.
  • I'm using Machine Learning for classifiying satellite imagery.

npz_json_converter's People

Contributors

2320sharon avatar dbuscombe-usgs avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

npz_json_converter's Issues

Cannot see all files when opening file directory

Currently when the system dialog to select a file is shown, not all files are displayed in the chosen directory. I suspect this line of code be may the solution.

root.filename =  filedialog.askopenfilename(title = "Select file",filetypes = (("weights file","*.h5"),("all files","*.*")))

awesome

I love the semi-transparency! love the checking for validity! great work - I am using it now

Opening json file programmatically

I am attempting to read the json file, but ran into an error

import json
with open('npz_data.json') as f:
    json_data = json.load(f)

I get the error

JSONDecodeError: Extra data: line 2 column 1 (char 899)

I used this to debug

and got the following message

Error: Parse error on line 18: ...46668956043956045} { "image_filename": ----------------------^ Expecting 'EOF', '}', ',', ']', got '{'

which is at the end of the first row...

so, I made a new function to convert this data to csv. It is pasted below

with open('../json/npz_data.json') as f:
    json_txt = f.readlines()

npzdatadict = {}
fields = ['image_filename', 
'label_image_filename', 
'annotation_image_filename', 
'user_ID', 
'classes_array', 
'num_classes',
 'classes_integer', 
 'classes_present_integer', 
 'classes_present_array',
  'pen_width', 
  'CRF_theta', 
  'CRF_mu', 
  'CRF_downsample_factor', 
  'Classifier_downsample_factor', 
  'prob_of_unary_potential', 
  'doodle_spatial_density']

 # make fields
 for f in fields:
     npzdatadict[f]=[]

# update all fields
for entry in json_txt:
    wjdata = json.loads(entry)
    for f in fields:
        npzdatadict[f].append(wjdata[f])

import pandas as pd
#convert to pandas dataframe, then to csv
pd.DataFrame.from_dict(npzdatadict).to_csv('npz_meta.csv')

that works, but do you know why json doesn't load?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.