Giter Club home page Giter Club logo

Comments (11)

aurooj avatar aurooj commented on August 18, 2024

Hi! Sorry for the late reply. It's crazy times. I will need to generate higher res masks for HOF, but it is definitely possible.

from hand-segmentation-in-the-wild.

test1230-lab avatar test1230-lab commented on August 18, 2024

Would this be done using xml annotations? If so I already made them and I could send them if you like.

from hand-segmentation-in-the-wild.

aurooj avatar aurooj commented on August 18, 2024

from hand-segmentation-in-the-wild.

zenoli avatar zenoli commented on August 18, 2024

Hi,
Are the high-res masks already online? I could not find them.

from hand-segmentation-in-the-wild.

test1230-lab avatar test1230-lab commented on August 18, 2024

out.zip
here, manually clean iirc

from hand-segmentation-in-the-wild.

zenoli avatar zenoli commented on August 18, 2024

@test1230-lab Thank you very much!

from hand-segmentation-in-the-wild.

test1230-lab avatar test1230-lab commented on August 18, 2024

from hand-segmentation-in-the-wild.

zenoli avatar zenoli commented on August 18, 2024

@test1230-lab
So the images you sent me are created using the polygon data from the XML right? I noticed two things:

  1. There are two hand masks missing (298 files in 'out.zip' vs 300 in 'images_orig_size').
  2. The indices in 'out.zip' do not lign up with the indices in 'imgages_orig_size'.

While these are both minor inconveniences (I can fix issue 2 manually without too much effort), I was wondering what the root of these two issues is? Do you have the script that created 'out.zip' available? Would you be willing to share it?

And I guess you don't have a "manually cleaned" version of the images?

from hand-segmentation-in-the-wild.

test1230-lab avatar test1230-lab commented on August 18, 2024

i think this is the one.

`import xmltodict
import glob
import os
from PIL import Image
from PIL import Image, ImageDraw
import argparse
from tqdm import tqdm


parser = argparse.ArgumentParser(description='simple parser')

parser.add_argument('--input_folder', type=str, default="./xml/",
                    help='path to only xml files', required=False)

parser.add_argument('--output_folder', type=str, default="output/", help='path to store the images ', required=False)
args = parser.parse_args()


def draw(image, pt_dict):
  pt_arr = []
  for p in pt_dict:
    pt_arr.append((int(p["x"]),int(p["y"])))
  image_draw = ImageDraw.Draw(image)
  image_draw.polygon(pt_arr, fill="#FFFFFF", outline ="white")
  del image_draw
  return image


def run_prog(in_folder, out_folder):
  #print(in_folder, out_folder)
  my_files = sorted(glob.glob(os.path.join(in_folder, "*.xml")))
  #print(my_files)
  for f in tqdm(my_files):
      try:
        if f.split(".")[-1].lower() not in "xml":
          print(f.split(".")[-1].lower())
          continue
        with open(f, 'r') as file:
          data = file.read().replace('\n', '')
          my_dict = xmltodict.parse(data)
          #print(data)
        #print(data)

        #print(my_dict)
        fname=my_dict['annotation']["filename"]
        fname_no = int(fname.replace(".jpg", ""))
        img_size_w =  int(my_dict['annotation']["imagesize"]["nrows"])
        img_size_h =  int(my_dict['annotation']["imagesize"]["ncols"])
        my_object = my_dict['annotation']['object']

        image = Image.new('RGB', (img_size_h, img_size_w))

        if  isinstance(my_object, dict):
          poly_pt_dict=my_object['polygon']
          pt_dict = poly_pt_dict['pt']
          image = draw(image, pt_dict)
        elif isinstance(my_object, list):
          #print(type(my_object))
          for el in my_object:
            #print(el)
            poly_pt_dict = el['polygon']
            pt_dict = poly_pt_dict['pt']
            image = draw(image, pt_dict)
            # pass
          #poly_pt_dict = my_object[-1]
          #continue
        #print(my_object)
        #poly_pt_dict=my_object['polygon']
        #print(poly_pt_dict)

        #print(pt_dict)


        #display(image)
        xx = (os.path.join(out_folder, f"{str(fname_no)}.jpg"))

        xx = xx[23:]
        #print(xx)

        test = './output2/' + xx
        xx = './images_original_size/' + xx
        print('xx',xx)
        #print(test)
        #break
        #print(xx,test)
        #print('xx',xx)
        #img = Image.open(xx)
        #img.save(test)
        os.rename(xx,test)
        image.save(os.path.join(out_folder, f"{str(fname_no)}.png"))
        #del image_draw
        del image
        del my_dict

      except:
          continue

if __name__ == "__main__":
  run_prog(args.input_folder, args.output_folder)

`

from hand-segmentation-in-the-wild.

zenoli avatar zenoli commented on August 18, 2024

Awesome, thx!

from hand-segmentation-in-the-wild.

aurooj avatar aurooj commented on August 18, 2024

Thanks @test1230-lab! closing this issue now.

from hand-segmentation-in-the-wild.

Related Issues (12)

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.