Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'size' has incorrect type (expected int, got float) #41

Open
allg00d opened this issue Nov 4, 2023 · 13 comments
Open

'size' has incorrect type (expected int, got float) #41

allg00d opened this issue Nov 4, 2023 · 13 comments

Comments

@allg00d
Copy link

allg00d commented Nov 4, 2023

I am just trying to run the first example in the Readme.md. I am running on an M1 Pro Mac. I did a conda install of Manim Community v0.17.3 and pip install of the python library (manim 0.17.3, manim-ml 0.0.24). I am getting the following TypeError:

manim -pql manim_test.py

Manim Community v0.17.3

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Blah/lib/python3.10/site-packages/manim/cli/render/command │
│ s.py:115 in render │
│ │
│ 112 │ │ │ try: │
│ 113 │ │ │ │ with tempconfig({}): │
│ 114 │ │ │ │ │ scene = SceneClass() │
│ ❱ 115 │ │ │ │ │ scene.render() │
│ 116 │ │ │ except Exception: │
│ 117 │ │ │ │ error_console.print_exception() │
│ 118 │ │ │ │ sys.exit(1) │
│ │
│ /Blah/lib/python3.10/site-packages/manim/scene/scene.py:223 │
│ in render │
│ │
│ 220 │ │ """ │
│ 221 │ │ self.setup() │
│ 222 │ │ try: │
│ ❱ 223 │ │ │ self.construct() │
│ 224 │ │ except EndSceneEarlyException: │
│ 225 │ │ │ pass │
│ 226 │ │ except RerunSceneException as e: │
│ │
│ /Blah/manim_test.py:18 in │
│ construct │
│ │
│ 15 │ def construct(self): │
│ 16 │ │ # Make the neural network │
│ 17 │ │ nn = NeuralNetwork([ │
│ ❱ 18 │ │ │ │ Convolutional2DLayer(int(1), int(7), int(3), filter_spacing=0.32), │
│ 19 │ │ │ │ Convolutional2DLayer(int(3), int(5), int(3), filter_spacing=0.32), │
│ 20 │ │ │ │ Convolutional2DLayer(int(5), int(3), int(3), filter_spacing=0.18), │
│ 21 │ │ │ │ FeedForwardLayer(3), │
│ │
│ /Blah/lib/python3.10/site-packages/manim_ml/neural_network/ │
│ layers/convolutional_2d.py:128 in init
│ │
│ 125 │ │ padding_dashed=True, │
│ 126 │ │ **kwargs, │
│ 127 │ ): │
│ ❱ 128 │ │ super().init(**kwargs) │
│ 129 │ │ self.num_feature_maps = num_feature_maps │
│ 130 │ │ self.filter_color = filter_color │
│ 131 │ │ if isinstance(padding, tuple): │
│ │
│ /Blah/lib/python3.10/site-packages/manim_ml/neural_network/ │
│ layers/parent_layers.py:46 in init
│ │
│ 43 │
│ 44 class VGroupNeuralNetworkLayer(NeuralNetworkLayer): │
│ 45 │ def init(self, *args, **kwargs): │
│ ❱ 46 │ │ super().init(*args, **kwargs) │
│ 47 │ │ # self.camera = camera │
│ 48 │ │
│ 49 │ @AbstractMethod
│ │
│ /Blah/lib/python3.10/site-packages/manim_ml/neural_network/ │
│ layers/parent_layers.py:10 in init
│ │
│ 7 │ def init(self, text=None, *args, **kwargs): │
│ 8 │ │ super(Group, self).init() │
│ 9 │ │ self.title_text = kwargs["title"] if "title" in kwargs else " " │
│ ❱ 10 │ │ self.title = Text(self.title_text, font_size=DEFAULT_FONT_SIZE / 3).scale(0.6) │
│ 11 │ │ self.title.next_to(self, UP, 1.2) │
│ 12 │ │ # self.add(self.title) │
│ 13 │
│ │
│ /Blah/lib/python3.10/site-packages/manim/mobject/text/text_ │
│ mobject.py:486 in init
│ │
│ 483 │ │ │ self.line_spacing = self._font_size + self._font_size * self.line_spacing │
│ 484 │ │ │
│ 485 │ │ color = Color(color) if color else VMobject().color │
│ ❱ 486 │ │ file_name = self.text2svg(color) │
│ 487 │ │ PangoUtils.remove_last_M(file_name) │
│ 488 │ │ super().init( │
│ 489 │ │ │ file_name, │
│ │
│ /Blah/lib/python3.10/site-packages/manim/mobject/text/text

│ mobject.py:814 in _text2svg │
│ │
│ 811 │ │ │ width = config["pixel_width"] │
│ 812 │ │ │ height = config["pixel_height"] │
│ 813 │ │ │ │
│ ❱ 814 │ │ │ svg_file = manimpango.text2svg( │
│ 815 │ │ │ │ settings, │
│ 816 │ │ │ │ size, │
│ 817 │ │ │ │ line_spacing, │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: Argument 'size' has incorrect type (expected int, got float)

@helblazer811
Copy link
Owner

I couldn't reproduce the issue, but I coded up what should hopefully be a workaround.
Try updating to the local branch by running

pip install git+https://github.com/helblazer811/ManimML.git

@allg00d
Copy link
Author

allg00d commented Nov 4, 2023

It got further, but ended up with the same exception.

Constructing layers
Current layer: Convolutional2DLayer
Current layer: Convolutional2DLayer
Current layer: Convolutional2DLayer
Current layer: FeedForwardLayer
Current layer: FeedForwardLayer

Now it is running into the same issue when it tries to construct NeuralNetwork at line 17 in the example.

@allg00d
Copy link
Author

allg00d commented Nov 4, 2023

BTW, this seems like it would great to use in my ML course at Berkeley. The students definitely struggle with visualizing this stuff.

@helblazer811
Copy link
Owner

Could you try putting print(DEFAULT_FONT_SIZE) at the top of the script after the manim import. I'm wondering if it is not divisible by 3 and that is causing issues. I got 48 on my system.

@allg00d
Copy link
Author

allg00d commented Nov 4, 2023 via email

@helblazer811
Copy link
Owner

Hmmm. Quite strange. The stack trace has the same error on line 10 of parent_layers.py?

I changed the division to integer division to see if that changes things.

Try installing again pip install git+https://github.com/helblazer811/ManimML.git

Also, integrating this into a course sounds amazing. Let me know if there is a way that I can help with that. I plan multiple extensions of this project in the future.

@allg00d
Copy link
Author

allg00d commented Nov 4, 2023 via email

@helblazer811
Copy link
Owner

I think perhaps your system is using this manimpango dependency to render text instead of Latex, which is what my system is doing (I also have an M1 Macbook Pro).

Do you know what version of manimpango you have?

pip list | grep ManimPango

@allg00d
Copy link
Author

allg00d commented Nov 4, 2023 via email

@helblazer811
Copy link
Owner

Perhaps try running pip install -U manimpango

@helblazer811
Copy link
Owner

I think it may be the ManimPango does not allow for non-integer sizes because of how it is coded under the hood. And the reason my code works is because it may not be using this dependency. Let me see if I can just ensure for the code you are running that the text font sizes are integer.

@helblazer811
Copy link
Owner

I think this may be related.
ManimCommunity/ManimPango#106

@AlieNiT
Copy link

AlieNiT commented Nov 12, 2023

I also had the same issue with manimpango. I could not make it work even with downgrading manimpango (It caused a more serious issue).
For now I just tried to get away with casting both size and line_spacing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants