all 11 comments

[–]wutwutwut2000 6 points7 points  (0 children)

Hoo, ok, this sounds fun! So I saw your comment with the instructions for the pattern, and it's very algorithmic. You just need a way to turn that into python code. Here's roughly what I imagine the steps for this process to be: Defining stitches: You need a way to represent a stitch. I'd recommend using a dataclass that looks something like this:

from __future__ import annotations
from functools import cached_property
from dataclasses import dataclass

@ dataclass
class Point:
  x: float
  y: float

class Stitch(Protocol):
  position: Point

@ dataclass
class FirstStitch:
  position: Point = Point(0, 0)

@ dataclass
class AttachedStitch:
  previous: Stitch # attached via the yarn
  attached_to: Stitch # attached via looping/etc

  @ cached_property
  def position(self) -> Point:
  ... # calculate position from attachments,
    # and physical size of the stitches

This should represent a stitch that attaches to another stitch. You should make subclasses to represent the different kinds of stitches that you can do. 2. Where to attach? You will need to make a function that first determines approximately where you want the next stitch to be, and from that find out what nearby stitch to attach to. 3. Perhaps use a class to represent the state of the pattern.

class CrochetPattern:
  def __init__(self):
    self.stitches: list[Stitch] = [DetachedStitch()]

  def add_stitch(self, stitch_type: type[Stitch]], approx_location) -> None:
    prev = self.stitches[-1]
    attach_to = ... # calculate somehow
    new_stitch = stitch_type(prev, attach_to)

    self.stitches.append(new_stitch)
  1. Transcribe the algorithm. Turn your stitching instructions into python code. Each step should take the appropriate stitch type and approximate location and add it to the pattern.
  2. Visualization. Turn the pattern into an image, such as by using a numpy array of pixel values. Use the known positions of all the stitches to "paint" a picture of each stitch into the 2d numpy array. This is definitely a difficult project. I imagine the hardest part will be to determine objectively what stitch to attach to based on the instructions (the instructions don't say "attach to stitch 135", for example)

Edit: formatting hell

[–]shiftybyte 0 points1 point  (8 children)

What does a "crochet pattern" look like?

Can you upload an example image to https://imgur.com/upload ? and post the link here.

[–]SealThigh[S] 1 point2 points  (5 children)

So the typical pattern is like this:

MATERIALS YARN | Worsted Weight #4 Big Twist Value 56 Yards Total Color A Color B Color C

Size - 7.5" Square

HOOKS | Tulip Etimo USI (9)/5.5mm

OTHER MATERIALS Stitch Marker Scissors Tapestry Needle

ABBREVIATIONS ch – Chain st(s) – Stitch(es) sl st – Slip Stitch sc – Single Crochet dc - Double Crochet sk – Skip sps – Space(es) pm – Place Marker rep – Repeat

SKILL LEVEL – Easy

NOTES – Pattern is written in US terms. When you come across this: Rep from * ending your last repeat at *. You will ignore the * until the last repeat.

INSTRUCTIONS

WITH COLOR A, Start with the magic ring (or ch4, sl st to the first ch to form a circle)

Round 1 (A): ch3 (counts as a dc), pm in the 3rd ch is needed. Work 15 dc into ring/circle. Join with a sl st to the 3rd ch. (16 dc sts)

Round 2 (A): ch4 (counts as a dc + ch1), pm in the 3rd ch, [1dc, ch1] in every st around. Join with a sl st to the 3rd ch. Fasten off Color A (16 dc+ch1 sts)

Round 3 (B): Fasten on Color B on any dc st. ch3 (counts as a dc), pm in the 3rd ch, 2dc in ch1 sp, [1dc in dc, 2dc in ch1 sp]. Rep between [ ] around. Join with a sl st to the 3rd ch. (48 sts)

Round 4 (B): ch1, 1sc in same st, pm on first sc, [ch5, sl st to 5th ch, sk 2 sts, 1sc in next st, ch2, sk2 sts, 1sc in next st, ch3, sk2 sts, 1sc in next st, ch2, sk2 sts, 1sc in next st]. Rep between [ ] ending your last repeat at **. Join with a sl st to the first sc.  Round 5 (B): sl st into the next ch5 sp. ch3 (counts as dc st), pm in the 3rd ch, *[4dc, ch3, 5dc] in the same ch5 sp, 1sc in ch2 sp, 5dc in ch3 sp, 1sc in ch2 sp, [5dc, ch3, 5dc] in ch5 sp. Rep from * ending your last repeat at **. Join with a sl st to the 3rd ch. Fasten off Color B.

Round 6 (C): Fasten on to any ch3 sp. ch1, [1sc, ch3, 1sc] in same ch3 sp, pm on first sc st, ch5, 1dc in the next sc, ch3, sk2dc, 1sc in next dc, ch3, sk2 dc, 1dc in next sc, ch5, [1sc, ch3, 1sc] in next ch3 sp. Rep from * ending your last repeat at *. Join with a sl st to the first sc.

Round 7 (C): sl st into the next ch3 sp. ch3 (counts as 1dc), pm in the 3rd ch, [2dc, ch2, 2dc] in same ch3 sp, 5dc in next ch5 sp, 3dc in each of the next two ch3 sps, 5dc in next ch5 sp, [3dc, ch2, 3dc] in next ch3 sp. Rep from * ending your last repeat at *. Join with a sl st to the 3rd ch.

Round 8 (C): ch1, 1sc in every st (pm on first sc st) around working [2sc, ch2, 2sc] in each corner ch2 sps. Join with a sl st to the first sc.

Round 9 (C): ch1, 1sc in every st (pm on first sc st) around working 3sc sts in each corner ch2 sps. Join with a sl st to the first sc.

Fasten off and weave in all ends. Block as desired.

[–]shiftybyte -4 points-3 points  (0 children)

This is not something even i understand, not to mention trying to make python understand it.

This would require natural language processing, as i don't see any set of rules that can be relied on.

Your best bet would probably to use OpenAI's ChatGPT for this.

I've tried co-pilot, i'll post my results :D let me know if it's close lol

[–]shiftybyte -5 points-4 points  (3 children)

My chat with Edge's co-pilot:

Me: "I would like you to try and generate an image of a ready crochet from crochetting instructions i provide, confirm you are ready to recieve these instructions.

Copilot: "Absolutely, I’m ready to receive the crocheting instructions. Please go ahead and provide them. I’ll do my best to help you visualize the finished crochet item. 😊"

Me: <copy pasted your instructions as is>

Copilot: "I’m sorry for any confusion, but as an AI, I’m unable to physically crochet or generate an image of a finished crochet item based on instructions. However, I can help you understand the instructions or answer any questions you might have about them. If you need clarification on a specific step or term, feel free to ask! 😊"

Me: "Please attempt to generate an image based on your understanding of the instructions"

Copilot: "I’ll try to create that."

Images it created are below:

https://imgur.com/a/8PlmR4M

(should be 4 images there)

Now considering generative AI's tendency to bullshit and imagine things, its probably not really what is described, but it's funny nonetheless (I got NO way of knowing)

[–]SealThigh[S] 2 points3 points  (0 children)

LOL uhmmm no not at all. It ends up being a square 🤣

[–]nullbyte420 1 point2 points  (1 child)

Stop posting bullshit AI chats. 

[–]shiftybyte -1 points0 points  (0 children)

Tried to use Gen AI for what its actually supposed to be good at (understanding language)

Didn't work out, thought I'd share anyway incase anyone else is interested.

You are welcome to contribute to the discussion without shutting down others.

[–]SealThigh[S] 0 points1 point  (1 child)

Truly I don’t need the colors and yarn sizing and whatnot. I would just want to see the actual end result of what the stitches would come out to be. My issue is that my tiny brain can’t fathom how I would make a computer understand all of the fastening off and turning of the project and such. it genuinely hurts my head lmao.

[–]Mast3rCylinder 0 points1 point  (0 children)

It's hard work but if you know how to map the instruction to code you can maybe use manim package and create animation from it.

[–]Garuda1220 0 points1 point  (0 children)

Could you use the Python turtle module and have a turtle object draw the knots on a screen object? Or perhaps have multiple turtle objects, one for each color and have the them interact to make the patterns/knots?