Maker

100 Days of Python, Project 081 – Morse Code Generator #100DaysofCode

I feel like these last 19 projects are more complex and should get their own post each.  Just skimming over what they are, they all seem to be quite a bit more complex than a lot of the previous projects, and they also are given no help or instruction, just “Make X”.

I wanted to comment a bit briefly on the course as a whole so far though.  I’ve really enjoyed it, and I have lots of idea of projects I WANT to do, and I have started on a few, but I’m doing my best to force myself to focus on finishing this course FIRST.  Eyes on the Prize, so to speak.  The flow overall is pretty good, though I noticed some of the course comments, many people were complaining a bit during some parts.  Mostly about the lack of videos during the final, third or so, of the course.  I admit, I kind of feel for them a bit, but I also do somewhat get the point.

The point is, at some point, you do need to do this stuff without everything being hand-holdey the whole way.

That said, she was doing a pretty good job of this already within each “Broader” topic.  For say, Turtle Graphics, she would start off being extremely “Do X, Do Y, Do Z” about pretty much every step of a project.  Next lesson, there would be a bit less, then by the third it would ask the students to do something, then give a solution.  Eventually it was just, “Do a while project” with “here is a solution”.  It was gradual over 5-6 lessons.  

It feels like she tried to do this quite a bit with the overall course as well, the problem is, when you end up in an area that is completely unfamiliar again, like the Flask sections, or the Data Analytics sections, it would be a bit nice to start each “New Section” with some videos and a bit more help.

Personally, I didn’t find it too much of a problem, I was already doing many of the projects without watching any of the videos, then watching videos afterwards to see how she did it.  The user comments also were really great for suggestions and ideas.

I would still recommend the course.  It seems to be one of Udemy’s best selling courses too.

Anyway, on with the project, and I admit, I am kind of adding some filler.

Day 81 – Morse Code Translator

Ok, so, compared to what the rest of the “Professional” level projects seem to be, this particular project felt stupid super easy.  Like, “am I doing something wrong” easy.  I may have even already done this one evening on CodeWars.com.  I even fleshed it out a bit just to make it more interesting.

The project was to translate a user input into Morse Code.

Even just thinking about that, at it’s core, it’s literally just find and replace on a string.

Step One – Create a Dictionary of Morse Code sequences and the equivalent Alphabet letters

Step Two – Get a User Input

Step Three – Loop through the Input and convert each character using the Dictionary to Morse Code

That is IT.  That’s nothing.  The assignment also specified “Text Based”, though I considered converting it to work in TKinter or maybe even Flask.

I did spruce things up a bit, I added a prompt so the user can translate additional strings.  I looked up how to make sound output, and added an option to play the Morse Code out over the PC Speaker, which was fun, and new useful information.

Anyway, it’s on Github, but this is the entire code.

import winsound
from time import sleep

# Morse Code
morse_code = {
    'a': '·−',
    'b': '−···',
    'c': '−·−·',
    'd': '−··',
    'e': '·',
    'f': '··−·',
    'g': '−−·',
    'h': '····',
    'i': '··',
    'j': '·−−−',
    'k': '−·−',
    'l': '·−··',
    'm': '−−',
    'n': '−·',
    'o': '−−−',
    'p': '·−−·',
    'q': '−−·−',
    'r': '·−·',
    's': '···',
    't': '−',
    'u': '··−',
    'v': '···−',
    'w': '·−−',
    'x': '−··−',
    'y': '−·−−',
    'z': '−−··',
    '0': '−−−−−',
    '1': '·−−−−',
    '2': '··−−−',
    '3': '···−−',
    '4': '····−',
    '5': '·····',
    '6': '−····',
    '7': '−−···',
    '8': '−−−··',
    '9': '−−−−·',
    ' ': '/'
}

# Loop Variable
keep_going = True
valid_answers = ["yes","y","no","n"]

# Sound Variables
frequency = 700  # Set Frequency To 2500 Hertz
duration_short = 100  # Set Duration To 100 ms == .1 second
duration_long = 300  # Set Duration To 300 ms == .3 second

while keep_going:
    # Get String of Text to Convert
    conversion_string = input("Please enter a string to convert to Morse Code:\n").lower()
    # Fresh Code String Each Time
    code_string = ""
    # Do the Conversion
    for letter in conversion_string:
        if letter in morse_code:
            code_string += morse_code[letter]+" "
        else:
            code_string += letter
    # Show the Result
    print("Your Morse Code is:\n")
    print(code_string)
    # Ask if the user wants to hear the sound
    go_on = ""
    while go_on not in valid_answers:
        go_on = input("Would you like to play this sound? (Yes/No) ").lower()
    # If Yes, Play the sound
    if go_on == "yes" or go_on == "y":
        for beep in code_string:
            #print(beep)
            if beep == "−":
                winsound.Beep(frequency, duration_long)
            elif beep == "·":
                winsound.Beep(frequency, duration_short)
            # Needs a brief pause
            sleep(.05)

    # See if the user wants to do another conversion.
    go_on = ""
    while go_on not in valid_answers:
        go_on = input("Translate another string? (Yes/No) ").lower()
    # Quit if no more conversions
    if go_on == "no" or go_on == "n":
        keep_going = False

A Progressive Journey Through Working With AI Art – Part 4 – Better Prompts

The next step in my journey to better AI Art, was better prompts. Which also has sort of landed me on just using one complex prompt I found and modifying it as needed, which works very well. I started off by adding more descriptive words to the basic prompts. Including Camera models which was suggested by quite a few people.

  • “In the Style of Manga”
  • “An oil Painting Of”
  • “A Pencil Sketch of”
  • “in the style of [artist]
  • “Realistic”
  • “Hyper-realistic”
  • Canon 5D

This worked better. But I started looking around on the Stable diffusion Sub-Reddits for good prompts to use. I came across the following Prompt:

, (humorous illustration, hyperrealistic, big depth of field, colors, night club scenery, 3d octane render, 4k, concept art, hyperdetailed, hyperrealistic, trending on artstation:1.1)

Negatives:
text, b&w, (cartoon, 3d, bad art, poorly drawn, close up, blurry, disfigured, deformed, extra limbs:1.5)

Which I have used and adapted quite a lot. Essentially, everything in front of the first Comma is your actual prompt. This is essentially, what I have been doing. Everything after refines things a lot. You can also change the background by editing the “night club scenery” bit.

Anyway, the rest of the post is sharing some more pics based on this prompt.

Prompt: “Tracer from Overwatch” +

As normal, really iffy on the hands, but still some neat concepts that could actually be skins in the game.

Prompt: Godzilla +

Prompt: Several different Batman Prompts (Batman Fighting, Batman Overlooking Gotham, Batman Battling Joker)

Prompt: The Joker +

These are some of my favorites so far. I am not a huge Joker Fan really, but they do a REALLY good job of portraying the more modern crazy that is The Joker. I actually left a few off because frankly, they are super creepy, but really are nice.

Prompt: Professor Layton

Again, it has no idea who Layton is, but still seems to do really well with the Aethetic of Layton. Which is kind of odd honestly.

Prompt: An Adorable Pixar Kitten

Feels like Pixar styled art is cheater mode a bit but these came out pretty good as well.

Three Prompts with similar results, A Norwegian Landscape, The Lord of the Rings, and Arya Stark,

It’s kind of crazy just how much better the results have gotten from previous attempts, especially just like, 6 months ago or something, when I started playing with this concept using online tools. That said, it also gets old pretty quick, and you end up with a lot of “Weird shit” output, extra limbs, weird proportions, extra elbows, odd faces. I can see how it might be useful to produce some generic banner backdrops and whatnot. I also can see it just getting even better, very rapidly. If hands can be figured out, that would be a real game changer.

A Progressive Journey Through Working With AI Art – Part 3 – Running Natively with Automatic1111

After experimenting with online sources, then running Stable Diffusion locally using Windows Subsystem for Linux, I wanted more, and better, because I knew my machine was capable of much more. So I looked into alternatives and found Automatic1111’s Stable Diffusion variant.

The core take away here, is how this is like night and day in performance and quality.

Previously, with WSL, I would run batches of prompts and seeds and maybe get a few okish results. Also, any dimensions larger than the base 512×512 would crash the thing and I’d get nothing. Basically, it definitely was not exploiting the full potential here. It also completely dogged my entire rig down while building an image, which took maybe 5-10 minutes for the actual processing to work.

It still dogs the machine down, but not nearly as much as it had been. And it takes like 10-20 SECONDS to produce an image. The image quality is also like 1000 times better, though not still without that “AI Art Wonkeyness” like these weird square cows.

—- Read More —-: A Progressive Journey Through Working With AI Art – Part 3 – Running Natively with Automatic1111 Read More

100 Days of Python, Projects 71-80 (but not really) #100DaysofCode

Ok, I’m going to be frank here.

I’m skipping most of the Data Analytics portion of this course.  It’s 9 Lessons, Day 71-80.  It is all done using Google Colab Notebooks, it’s all extremely, extremely, extremely, repetitive, yet I am not really feeling like I am learning anything.

Every lesson amounts to, Open this Google Collab Notebook, which is a new and… interesting tool, I guess it’s similar to a Jupyter Notebook.  It’s basically, running “code” in weird choppy step by step chunks.  Each lesson amounts to.

  • Open a provided CSV file.
  • Make a Graph
  • Format the Graph.
  • Maybe do some layered graphs.
  • Sometimes the type of graph is different (line, bar, scatter, etc).

It’s dull, it’s repetitive, I have almost zero interest in statistics and data science honestly.  Fun Fact, Statistics is the one class I dropped in college.  I could have gotten a minor in Math with my Mechanical Engineering Degree with one more math credit, so I took Statistics.  It was the only class I had any actual homework in my last semester, everything else was writing reports, the homework was absolutely brutal, and the entire class felt like butchering math to create Conformation Bias.  It was stupid, it doesn’t account for nuance and one offs, which is what you should actually care about because those are the failure points.  I could go on and on.

Anyway, the sections tarted out pretty fun, learning  new tool, making fancy graphs, then halfway through I found I was just copying and pasting answers from the lecture because I just wanted it to be over and I didn’t care about the material.  

So I’m just, skipping it. This isn’t a graded University Course, hell I have made plenty of small side projects during this course to fill in the idea of “100 Projects in 100 Days”.

Also, if I wanted to make pretty charts, I would just use Microsoft Excel.  Because I am already pretty good at that.

This leads into the final “stretch” of this course, which I have already started working on some.  The Final 19 Projects, which are all basically, open ended suggestions.  There is a Data Analytics one in there, which I actually probably will go ahead and throw together some Charts for.  I have the perfect Data Set for it, ever since I bought my car, back in 2015, I’ve tracked my mileage and fuel usage every time I fill up (in Excel).  I can dump out a huge CSV was and manipulate that data in Google Collab or a Jupyter Notebook.

A Progressive Journey Through Working With AI Art – Part 2 – Running Locally

My initial foray into doing AI Art locally involved Stable Diffusion, which can be found here. This path ended up being sort of, multi staged. Initially I set it all up to run off the command line through PowerShell and Python. I ran through several prompts aver a few days off and on with iffy results (above). At some point I closed it down. When I came back, I couldn’t get it to run again. I couldn’t figure out WHY and so I gave up and nuked it to start fresh. (The problem was I forgot to use the Python Virtual Environment, DUUUUH).

Part 1 can be found here.

Side Note, Unfortunately, I don’t know the prompts for many of these because my initial runs just produced file names with numbers for file names.

—- Read More —-: A Progressive Journey Through Working With AI Art – Part 2 – Running Locally Read More