meijieru / crnn.pytorch

Convolutional recurrent network in pytorch
MIT License
2.4k stars 658 forks source link

TypeError: __init__() takes from 1 to 4 positional arguments but 9 were given convert_dataset.py #15

Closed ahmedmazari-dhatim closed 7 years ago

ahmedmazari-dhatim commented 7 years ago

Hello, to run convert_dataset.py l give the path to the output ofcreate_dataset.py which are data.mdb and lock.mdb

When l execute convert_dataset.py

if __name__ == "__main__":
    convert('/home/ahmed/Downloads/sample/data/training', '/home/ahmed/Downloads/sample/data/training-ordered')

l get the following error :

Traceback (most recent call last):
  File "/home/ahmed/Downloads/crnn.pytorch-master/tool/convert_dataset.py", line 55, in <module>
    convert('/home/ahmed/Downloads/sample/data/training', '/home/ahmed/Downloads/sample/data/data-ordered')
  File "/home/ahmed/Downloads/crnn.pytorch-master/tool/convert_dataset.py", line 17, in convert
    originDataset = dataset.lmdbDataset(originPath, 'abc', *args)
TypeError: __init__() takes from 1 to 4 positional arguments but 9 were given
ahmedmazari-dhatim commented 7 years ago

The problem is solved as follow :
remove * in args :
originDataset = dataset.lmdbDataset(originPath, 'abc', *args) Becomes :
originDataset = dataset.lmdbDataset(originPath, 'abc', args)

meijieru commented 7 years ago

I have removed convert_dataset.py.

ahmedmazari-dhatim commented 7 years ago

@meijieru , so there will be no way to run the code with a variable size images ?

meijieru commented 7 years ago

You could sort dataset when create dataset.

RabiaNisar commented 6 years ago

when i run this code i get following error... the code is given below error.. pls help thank you Traceback (most recent call last): File "C:/Users/bleh/PycharmProjects/spaceWar/space.py", line 123, in player = Player('triangle' , 'white' , 0 , 0) TypeError: init() takes from 1 to 4 positional arguments but 5 were given


import os import random

Import the Turtle module

import turtle turtle.fd(0) turtle.speed(0) turtle.bgcolor("black") turtle.ht() turtle.setundobuffer(1) turtle.tracer(1) class Sprite(turtle.Turtle):

def _init_(self, spriteshape, color, startx, starty):
    turtle.Turtle._init_(self, shape = spriteshape )
    self.speed(0)
    self.penup()
    self.color(color)
    self.fd(0)
    self.goto(startx, starty)
    self.speed = 1
def move(self):
    self.fd(self.speed)

    if self.xcor() > 290:
        self.setx(290)
        self.rt(60)
    if self.xcor() < -290:
        self.setx(-290)
        self.rt(60)
    if self.ycor() > 290:
        self.sety(290)
        self.rt(60)
    if self.ycor() < -290:
        self.sety(-290)
        self.rt(60)

def is_collision(self, other):
    if (self.xcor() >= (other.xcor() - 20)) and \
        (self.xcor() <= (other.xcor() + 20)) and \
        (self.ycor() >= (other.xcor() - 20)) and \
        (self.ycor() <= (other.xcor() + 20)):
        return True
    else:
        return False

class Player(Sprite): def init(self, spriteshape, color, startx, starty): Sprite.init(self, spriteshape, color, startx, starty ) self.speed = 4 self.lives = 3 def turn_left(self): self.lt(45)

def turn_right(self):
    self.rt(45)

def accelerate(self):
    self.speed -= 1

def decelerate(self):
    self.speed -= 1

class Enemy(Sprite): def init(self, spriteshape, color, startx, starty): Sprite.init(self, spriteshape, color, startx, starty ) self.speed = 6 self.setheading(random.randint(0,360))

class Missile(Sprite): def init(self, spriteshape, color, startx, starty): Sprite.init(self, spriteshape, color, startx, starty ) self.speed = 20 self.status = "ready" self.goto(-1000, 1000) def fire(self): if self.status == "ready": self.goto(player.xcor(), player.ycor()) self.setheading(player.heading())

        self.status = "firing"

def move(self):
    if self.status == "ready":
        self.goto(-1000, 1000)
    if self.status == "firing":
        self.fd(self.speed)
        #Border check
    if self.xcor() < -290 or self.xcor() > 290 or \
        self.ycor()< -290 or self.ycor()> 290:
        self.goto(-1000, 1000)
        self.status = "ready"

class Game(): def init(self): self.level = 1 self.score = 0 self.state = "playing" self.pen = turtle.Turtle() self.lives = 3

def draw_border(self):
    #Draw border
    self.pen.speed(0)
    self.pen.color("white")
    self.pen.pensize(3)
    self.pen.penup()
    self.pen.goto(-300, 300)
    self.pen.pendown()
    for side in range(4):
        self.pen.fd(600)
        self.pen.rt(90)
    self.pen.penup()
    self.pen.ht()

Create game object

game = Game()

Draw the game border

game.draw_border()

Create my sprites

player = Player('triangle' , 'white' , 0 , 0) enemy = Enemy("circle" , "red", -100, 0) missile = Missile("triangle", "yellow", 0, 0)

Keyboard bingings

turtle.onkey(player.turn_left, "Left") turtle.onkey(player.turn_left, "Right") turtle.onkey(player.turn_left, "Up") turtle.onkey(player.turn_left, "Down") turtle.listen()

Main game loop

while True: player.move() enemy.move()

#check for a collision with the player
if player.is_collision(enemy):
    x = random.randint(-250, 250)
    y = random.randint(-250, 250)
    enemy.goto(x,y)
#check for a collision between missile and the enemy
if missile.is_collision(enemy):
    x = random.randint(-250, 250)
    y = random.randint(-250, 250)
    enemy.goto(x,y)
    missile.status = "ready"

Create my sprites

player = Sprite("triangle", "white", 0, 0)

delay = raw_input("Press enter to finish. >")