foundation-multimodal-models / CAPTURE

Apache License 2.0
36 stars 0 forks source link

必须放在if __name__ == '__main__'里面才能运行 #4

Open yutchina opened 2 months ago

yutchina commented 2 months ago

你好 我直接运行 from capture_metric.capture import CAPTURE refs = { 'example_0': [ "The image depicts a busy city street with cars running in the foreground, including a red car and a white truck. The street is surrounded by green trees. In the backgound of the image, modern edifices and a clock tower stand under a clear blue sky. ", "The image depicts a busy city street with cars running in the foreground, including a red car and a white truck. The street is surrounded by green trees. In the backgound of the image, modern edifices and a clock tower stand under a clear blue sky. " ], } preds = { 'example_0': [ "The image shows a red car, a white truck and other automobiles running on a city road. Pedestrians are walking on the side. Tall buildings can be seen under a clear blue sky." ] }

evaluator = CAPTURE() score = evaluator.compute_score(refs, preds) print(f"CAPTURE score: {score}") 但是出现了下面的错误: RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.

不知道是否有可以解决的方法呢?

hanhan68 commented 1 day ago

你好 我直接运行 from capture_metric.capture import CAPTURE refs = { 'example_0': [ "The image depicts a busy city street with cars running in the foreground, including a red car and a white truck. The street is surrounded by green trees. In the backgound of the image, modern edifices and a clock tower stand under a clear blue sky. ", "The image depicts a busy city street with cars running in the foreground, including a red car and a white truck. The street is surrounded by green trees. In the backgound of the image, modern edifices and a clock tower stand under a clear blue sky. " ], } preds = { 'example_0': [ "The image shows a red car, a white truck and other automobiles running on a city road. Pedestrians are walking on the side. Tall buildings can be seen under a clear blue sky." ] }

evaluator = CAPTURE() score = evaluator.compute_score(refs, preds) print(f"CAPTURE score: {score}") 但是出现了下面的错误: RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.

不知道是否有可以解决的方法呢?

请问解决了吗?想借鉴一下

yutchina commented 1 day ago

你好 我直接运行 from capture_metric.capture import CAPTURE refs = { 'example_0': [ "The image depicts a busy city street with cars running in the foreground, including a red car and a white truck. The street is surrounded by green trees. In the backgound of the image, modern edifices and a clock tower stand under a clear blue sky. ", "The image depicts a busy city street with cars running in the foreground, including a red car and a white truck. The street is surrounded by green trees. In the backgound of the image, modern edifices and a clock tower stand under a clear blue sky. " ], } preds = { 'example_0': [ "The image shows a red car, a white truck and other automobiles running on a city road. Pedestrians are walking on the side. Tall buildings can be seen under a clear blue sky." ] } evaluator = CAPTURE() score = evaluator.compute_score(refs, preds) print(f"CAPTURE score: {score}") 但是出现了下面的错误: RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.

不知道是否有可以解决的方法呢?

请问解决了吗?想借鉴一下

只能在自己的主程序里面加一个if name == 'main',然后把这个capture import进来

hanhan68 commented 1 day ago

你好 我直接运行 from capture_metric.capture import CAPTURE refs = { 'example_0': [ "The image depicts a busy city street with cars running in the foreground, including a red car and a white truck. The street is surrounded by green trees. In the backgound of the image, modern edifices and a clock tower stand under a clear blue sky. ", "The image depicts a busy city street with cars running in the foreground, including a red car and a white truck. The street is surrounded by green trees. In the backgound of the image, modern edifices and a clock tower stand under a clear blue sky. " ], } preds = { 'example_0': [ "The image shows a red car, a white truck and other automobiles running on a city road. Pedestrians are walking on the side. Tall buildings can be seen under a clear blue sky." ] } evaluator = CAPTURE() score = evaluator.compute_score(refs, preds) print(f"CAPTURE score: {score}") 但是出现了下面的错误: RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.

不知道是否有可以解决的方法呢?

请问解决了吗?想借鉴一下

只能在自己的主程序里面加一个if name == 'main',然后把这个capture import进来

好滴