Monday, February 26, 2024

Javascript webp to png converter

[Done with programmer's assistants: Gemini, DALL-E]
OpenAI's DALL-E produces images, but as webp files which can be awkward to work with. I have code here below for a web page that you can save locally that will allow you to select and convert a webp file. Meantime, here's the working conversion routine:

Convert WebP to PNG

OpenAI should fix this (as well as the response issues which has me using Gemini and Poe more often than not). Having to convert the image is a dumb workaround, but that is what you are left with. I have, in the past had to do various things with images, and although it can be a bit awkward if you are not familiar with it, ImageMagick is surprisingly competent with conversions and a vanilla type conversion is intuitively simple. Confusingly, the ImageMagick executable is 'convert'. To convert a webp to a png: 

magick convert WhyThis.webp WhyThis.png

** With some installations, convert can be called on its own: convert in.webp out.png

You can find ImageMagick here. 

https://imagemagick.org/index.php

Note: I took a look at the files output as webp, gif, and png . The webp savings in size are considerate: 

657,688 in.webp

1,247,110 Out.gif

3,391,612 Out.png

If I were in charge, I probably would have gone with the webp as well, but I would have made it clear it was happening, and why, and I would have provided a tool to at least convert that locally. 

HTML Page -- Convert WebP to PNG

Monday, February 19, 2024

Fake is the New Black

I am overdue writing up the fact that rapid AI advances have now made scammers much more dangerous. People don't seem to realize that things we thought were off in the future last year are here already and becoming so sophisticated so quickly they are, and will be, catching people off-guard. Until we have much better safeguards in place everywhere, you need to be very much on guard. Update passwords and put in place 2 factor authentication everywhere. A video call of a loved one can and eventually will be faked.

If you don't know for sure that it's real, assume it's fake. This year you will have a very hard time knowing it's real.

Unless you are expecting a contact from some source, you should start with a default condition that it is a scam. Scammers can now easily fake the voice of a person sufficiently accurate and undetectable that they can get into banking systems that use voice recognition as a security measure.

An AI system can now tell if you have type 2 diabetes just by listening to about ten seconds of your voice. A scammer's business is to know how to dupe people into lowering their defenses. They can now be aided by AI for working out a particular strategy tailored specifically to fool you personally. That could include AI recognizing from your voice what strategy would work best on you. They can fake any person's real-time moving image as well as their voice.

The link below describes a scam that was successful in fooling someone that they were in a group meeting with their Chief Financial Officer and other employees. All except the employee being scammed were deep fakes and they were convincing enough that he released more than 25 million dollars to the scammers. 

Sunday, February 18, 2024

AI is Smarter Than You, But That’s Not Saying Much


AI is Smarter Than You, But That’s Not Saying Much

Artificial Intelligence (AI) has achieved remarkable feats, from passing bar exams and medical boards to acing SATs and scoring like a genius on IQ tests. However, it’s important to remember that AI doesn’t think the way we do. In fact, for some definitions of ‘think’, it doesn’t think at all.

The Limitations of AI

AI can make unexpected mistakes, such as adding extra limbs to animals in generated images or hallucinating facts and supporting references. These are errors that a human or even an animal with lived experience would never make. In the three-dimensional real world, objects cannot pass through each other like ghosts. While an AI can tell you this in text, it often violates this rule in practice because it doesn’t understand it holistically the way we do.

The Risks of Relying on AI

As AI continues to improve in areas like text construction, photorealistic image generation, full-motion video, invention, and other tasks we consider requiring intelligence, the danger of relying on its ‘common sense’ and the facticity of its output rises. Imagine an AI designing a nuclear facility with a perfectly operating emergency ‘off button’. However, the AI also constructs a robot that, although it looks human, has a hand constructed so it cannot push the button. Despite testing every other conceivable thing in simulation, missing that one vital point could spell disaster.

The Subtlety of AI Mistakes

We can spot many of the mistakes that AI makes, but some strange ones can slip past us. For instance, an AI company recently released dramatically accomplished 3D videos wholly generated by AI. One of the videos, which many were particularly impressed with, had a brief section where a cat had a third arm. Its manifestation was subtle enough that nobody caught it until it was in wide distribution.

Conclusion

As AI continues to get better at things, the danger that things will both slip past and be problematic when they do increases. Don’t be fooled by the impressive achievements of AI. It’s smarter than you in some ways, but that’s not saying much. Always remember that AI, no matter how advanced, lacks the holistic understanding and common sense that come naturally to humans. 

Friday, February 16, 2024

Avoiding Grab Bag Politics


In my observations, well-intentioned individuals forming political platforms often fall into what I describe as "Grab Bag Politics," closely related to Pork Barrel Politics. This approach focuses on seemingly beneficial but ultimately minor issues, distracting from more critical matters. For instance, while it's admirable to want every child to have shoes they like, making it a legislative priority overshadows more significant issues, risking the neglect of broader principles like children's overall well-being and prosperity. Such specificity in legislation is impractical, as it's impossible to address every detail and maintain a holistic balance.

Diverse priorities within a group aiming for societal change can lead to resource allocation conflicts, highlighting the need for a more generalized approach to ensure no essential aspect is overlooked and to manage priorities effectively. I advocate for a system that guarantees everyone a fair share of resources, maximizes individual autonomy, and appropriately divides collective responsibilities such as foreign policy and defense from personal choices.

As we face the transformative impact of AI, with its promise of reduced scarcity and increased abundance, we confront challenges like job displacement and the potential for an education revolution through personalized AI instruction. However, without intervention, this technological shift could exacerbate inequality, leading to a dystopian reality of widespread impoverishment. By forming a united platform in democratic societies like Canada, we can establish a government that genuinely represents its people and secures a prosperous future for all, inspired by models like Norway's social compact and sovereign wealth fund. This approach can help avoid the pitfalls of "Grab Bag Politics" and focus on creating a fair and equitable society.

Monday, February 12, 2024

Try AI right now

If you have yet to actually use an AI chat system, you are in for a surprise. 

I will be writing up how the magic bit of GPTs relates to work I started more than thirty years ago. My work makes me think that current AI has found the magic I was looking for and that magic is very magic indeed. If what has been found is what it appears to be, there is much, much more magic to come, and it is almost certain to come much more quickly than people think. These systems are helpful already if you know how to use them, but they are going to be absolutely indispensable before the end of the year. It's moving that fast. 

Here is the prompt I gave Poe:  

Can you write quick step by step instructions for a new user to set up with Poe.com, and give a few examples an ordinary person new to AI would enter as prompts and what they could expect?

Here is Poe's response:

Certainly! Here are step-by-step instructions for a new user to set up an account with Poe.com:

Visit the website: Open your web browser and go to https://poe.com/login.

Update -- other websites:

https://chat.openai.com/

https://gemini.google.com/app

https://groq.com/

Choose your preferred login method: You have the option to continue with Google, continue with Apple, or use your phone. Select the method that you're most comfortable with.

Agree to Poe's Terms of Service and Privacy Policy: Read through the terms of service and privacy policy, and if you agree with them, click on the checkbox or button indicating your acceptance.

Sign up or log in: If you're a new user, you'll need to create an account by providing the required information, such as your name, email address, and a password. If you already have an account, simply log in using your credentials.

Set up your profile: Once you've logged in, you may have the option to set up your profile. This step is usually optional but can provide a more personalized experience.

Explore the chat interface: After completing the registration process, you'll be directed to the chat interface. This is where you can interact with Poe and ask questions or provide prompts.

Examples of prompts for an ordinary person new to AI:

"What is artificial intelligence?"

"How can AI be used in everyday life?"

"Tell me about the latest advancements in AI technology."

"Can you explain machine learning in simple terms?"

"What are the ethical considerations surrounding AI?"

When entering these prompts, you can expect Poe to provide helpful and informative responses based on its training and knowledge. It can explain concepts, provide examples, and offer insights related to the field of artificial intelligence. Remember that Poe's responses are generated based on pre-existing data and may not always reflect real-time information or current events.

Saturday, February 3, 2024

Show your work

Quora paywalled my answer to a question. 

As a high school junior with only basic coding experience, what should I do now to stand out on college resumes if my goal career is as a full-stack developer?

You should do a project where you can learn and build something that demonstrates you are able to do something useful. You can show what you have done, and having muddled through it you can explain what you did. Put it up on GitHub so you can point somebody to it and to show that you at least know what revision control is.

Note: AI is going to change everything fast so you need to add AI to your workflow. In this example here, use something like ChatGPT or Poe, etc. to ask/answer questions you need answered as you go along. When it comes to adding the database bit to your mini website, learn how to enter the code into an AI system and how to get it to aid you to write what you need. If you are organized and can walk through an AI session to go from this to that you can put up a blogger site, copy and paste this text, copy and paste your AI session, screenshots of the working system, code on Github, and perhaps a tree of the development system where it all resides you will be able to not only point to the working code you will be able to show how you did it. [Note: I taught core CS courses in the past :)]

Here’s an idea. Put together a web page for chat with a python web server. Create a script to load the server. Load the server using the script you created and then run two separate browser sessions loading the URL below. Chat with yourself about what a fine fellow you are.

http://localhost:5000

Test the chat to make sure you have it running OK, then pretty it up and maybe add a little bit of function like running another script for a program you have compiled in C/C++ or whatever. If you create a VirtualBox VM with an OS, do the whole thing under that VM, and add code to do something in a database (Example code to show how to use SQLite at the end) you will have have something that shows a stack from OS to development environment, scripting, web server, database, and user interface.

Code for a working web server is below. Note that flask expects your index.html file in a directory below where you run it called ‘templates’. Install python (you’ll have to look that up) on your machine, and install flask-socketio, eventlet, and flask:


pip install flask-socketio eventlet flask


./chatserver.py


from flask import Flask, render_template 

from flask_socketio import SocketIO, emit 

 

app = Flask(__name__) 

app.config['SECRET_KEY'] = 'secret_key' 

socketio = SocketIO(app) 

 

messages = [] 

 

@app.route('/') 

def index(): 

    return render_template('index.html', messages=messages) 

 

@socketio.on('connect') 

def handle_connect(): 

    emit('message', 'Connected to the server') 

 

@socketio.on('send_message') 

def handle_send_message(data): 

    message = data['message'] 

    messages.append(message) 

    emit('message', message, broadcast=True) 

 

if __name__ == '__main__': 

    socketio.run(app, host='0.0.0.0', port=5000, debug=True) 

./templates/index.html


<!DOCTYPE html> 

<html> 

<head> 

    <title>Chat Server</title> 

</head> 

<body> 

    <h1>Chat Server</h1> 

    <div id="messages"> 

        {% for message in messages %} 

            <p>{{ message }}</p> 

        {% endfor %} 

    </div> 

    <form id="message-form"> 

        <input type="text" id="message-input" name="message" placeholder="Enter your message"> 

        <button type="submit" id="send-button">Send</button> 

    </form> 

    <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.5.1/socket.io.js"></script> 

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> 

    <script> 

        $(document).ready(function() { 

            var socket = io(); 

 

            socket.on('connect', function() { 

                console.log('Connected to the server'); 

            }); 

 

            socket.on('message', function(message) { 

                $("#messages").append("<p>" + message + "</p>"); 

            }); 

 

            $("#message-form").submit(function(event) { 

                event.preventDefault(); 

                var message = $("#message-input").val(); 

                socket.emit('send_message', { message: message }); 

                $("#message-input").val(""); 

            }); 

        }); 

    </script> 

</body> 

</html> 

Below is a python program that uses SQLite to create a table, insert some rows into it, and then retrieve the data. SQLite is a lightweight, disk-based database that doesn’t require a separate server process. If you hack the python server and html so that you can build, populate, and use a SQLite database from the above little set of code you will have done something that shows you can at least be a good helper. Best of luck!

The example will be simple for clarity:

1. Create a table named example_table with two columns: id (integer) and name (text).

2. Insert a few rows into the table.

3. Select the rows and print them out.

Here’s the Python code:


import sqlite3

# Connect to SQLite database (or create it if it doesn't exist) 

conn = sqlite3.connect('example.db') 

# Create a cursor object using the cursor method 

cursor = conn.cursor() 

# Create table 

cursor.execute('''CREATE TABLE IF NOT EXISTS example_table 

                  (id INTEGER PRIMARY KEY, name TEXT)''') 

# Insert rows 

cursor.execute("INSERT INTO example_table (name) VALUES ('Alice')") 

cursor.execute("INSERT INTO example_table (name) VALUES ('Bob')") 

cursor.execute("INSERT INTO example_table (name) VALUES ('Charlie')") 

# Commit the changes 

conn.commit() 

# Select and display all rows 

cursor.execute("SELECT * FROM example_table") 

rows = cursor.fetchall() 

for row in rows: 

    print(row) 

# Close the connection 

conn.close() 

This script sets up a basic SQLite database, adds some entries, and then fetches and prints them. Remember to handle database connections and exceptions properly in a production environment.

Friday, February 2, 2024

How much more powerful will artificial intelligence get in the future?

Below is a post that I made on Quora that Quora might make inaccessible due to their monetization thing, so... 

Profile photo for Bob Trower

First, let’s have a look at underlying aspects. One aspect is the advancements of underlying hardware according to Moore’s law. Much has been said about how it must end, but it has not ended yet and with a movement to better technology due to AI (say, graphene processors), it is not likely to end soon. Also, I have overlain a line on the Kurzweil derived graph and you can see that exponential and then some in practice.

Another underlying aspect is that investment in AI is increasing. Tools are increasing in power, but they are also increasing in numbers.

Another is that they are increasing in terms of their applications and those have a synergistic effect. Among other things, time saved by AI in one thing frees up more time to work on AI. They are more powerful, there is more of them and they affect more things. Assuming that these all contribute a 10x, you are looking at 1000x in aggregate power.

I expect that AI will be superhuman by the end of 2024 and at worst, by the end of the decade nobody will deny that AI has exceeded human intelligence by a large margin.

In medicine, AI holds immense potential for personalized healthcare. Advanced AI algorithms can analyze large volumes of patient data, including medical records, genomic information, and imaging data, to provide tailored diagnoses and treatment plans. AI can assist in early disease detection, drug discovery, and precision medicine, leading to more effective and efficient healthcare outcomes.

In chemistry, AI can aid in drug discovery and development. By analyzing vast chemical databases and simulating molecular interactions, AI algorithms can identify potential drug candidates, predict their properties, and optimize their efficacy. This can accelerate the discovery of new medications and facilitate the design of novel materials with specific properties.

In physics, AI can contribute to data analysis and modeling. AI techniques such as deep learning can extract meaningful patterns from large datasets generated by particle accelerators and observatories. This can lead to advancements in particle physics, astrophysics, and cosmology, helping scientists gain deeper insights into the fundamental workings of the universe.

In mathematics, AI can assist in solving complex problems and proving theorems. AI algorithms can explore vast mathematical spaces, identify patterns, and generate conjectures. This can aid mathematicians in making new discoveries, validating conjectures, and providing insights into unexplored mathematical territories.

In biology, AI can enhance our understanding of complex biological systems. AI algorithms can analyze genomic data, model protein folding, and simulate biological processes. This can lead to advancements in fields such as genomics, synthetic biology, and drug design, enabling breakthroughs in personalized medicine and bioengineering.

In materials science, AI can accelerate materials discovery and design. AI algorithms can predict material properties, identify novel materials with desired characteristics, and optimize their synthesis processes. This can lead to the development of advanced materials for energy storage, electronics, and sustainable technologies.

Regarding embodied AI, AI systems that interact with the physical world through robotic bodies can have a profound impact. Embodied AI can enable robots to navigate complex environments, manipulate objects, and interact with humans more intuitively. This has applications in areas such as healthcare, manufacturing, and autonomous transportation.

Augmented reality (AR) and virtual reality (VR) can be enhanced by AI, providing realistic and immersive experiences. AI algorithms can improve object recognition, scene understanding, and gesture recognition, enhancing the quality and interactivity of AR/VR applications across various domains, including education, entertainment, and training simulations.

Cybernetics, the study of systems and control in humans and machines, can benefit from AI advancements. AI can enable more sophisticated human-machine interfaces, brain-computer interfaces, and assistive technologies. This can enhance human capabilities, enable neuroprosthetics, and improve the quality of life for individuals with disabilities.

Finally, AI's power lies not only in its impact across scientific disciplines but also in amplifying developer productivity and its own advancement. AI tools and frameworks streamline the development process, automate repetitive tasks, and enable faster prototyping and experimentation. This boosts developer productivity and facilitates the creation of cutting-edge AI applications. Furthermore, AI's ability to learn from data and improve its own performance, known as machine learning, allows AI systems to continually evolve and become more powerful over time.

In conclusion, the future of AI holds immense potential in medicine, chemistry, physics, math, biology, materials science, embodied AI, AR/VR, and cybernetics. Its power lies in its ability to augment human capabilities, accelerate scientific advancements, and amplify developer productivity. As AI continues to advance, it is poised to revolutionize multiple domains, shaping the future of technology, science, and society.

Canadians Should Be Better Than This

I see Pierre Poilievre illegitimately harnessing the warranted righteous anger of Canadians with the powers that be. He's fooling the le...