Category: computer science

  • Sautoyrs: Erotic literature generation platfrom

    Sautoyrs: Erotic literature generation platfrom

    After one month work, today is the first day that I opened my erotic literature generation platform to the public: https://github.com/sudoghut/Sautoyrs

    It is a web application that generates romantic and explicit sexual stories automatically using a large language model. It creates interactive narratives between two characters with customizable settings. It can only work on Chrome /Firefox on desktop or laptop.

    Sautoyrs came from satyr:

    In Greek mythology, a satyr[a] (Ancient Greek: σάτυρος, romanized: sátyros, pronounced [sátyros]), also known as a silenus[b] or silenos (Ancient Greek: σειληνός, romanized: seilēnós [seːlɛːnós]), and sileni (plural), is a male nature spirit with ears and a tail resembling those of a horse, as well as a permanent, exaggerated erection. Early artistic representations sometimes include horse-like legs, but, by the sixth century BC, they were more often represented with human legs.[4] Comically hideous, they have mane-like hair, bestial faces, and snub noses and they always are shown naked. Satyrs were characterized by their ribaldry and were known as lovers of wine, music, dancing, and women. They were companions of the god Dionysus and were believed to inhabit remote locales, such as woodlands, mountains, and pastures. They often attempted to seduce or rape nymphs and mortal women alike, usually with little success. They are sometimes shown masturbating or engaging in bestiality.

    Since that it can generate conversations automatically, I added auto into satyrs. It became sautoyrs.

    This is the web traffic statistics for the first day. Not as good as I expected:

    Anyway, I have done my best.

  • Debugging Pitfalls: Async forEach and Slice Memory Sharing in JavaScript

    From last Thursday until just now (Saturday), two issues confused me a lot:

    forEach is synchronous, not asynchronous

    This is a fundamental concept, but problems can arise when you assume a block of code will execute synchronously while using forEach. For some reason, if that block of code becomes asynchronous, it could lead to unexpected issues.

    slice creates a shallow copy

    shortConversation = […systemPrompt, …chatThread.current.slice(-(memoryLength + 2 - 1))];

    The slice method causes shortConversation and chatThread to share part of the memory, which led to unexpected behaviors.

    The corrected code is as follows:

    shortConversation = [...systemPrompt, ...structuredClone(chatThread.current.slice(-(memoryLength + 2 - 1)))];

    Using structuredClone ensures that shortConversation and chatThread are completely independent.

  • 【Imghorce】Shopping and gift 背後的故事

    【Imghorce】Shopping and gift 背後的故事

    最近忙著做戀愛腦 AI 自動談戀愛的 project, 好久沒更新圖片了。年底有一個巨大的大眾主題~ 它就是購物和禮物。那麼做一期購物和禮物叭~

    https://imghorce.oopus.info/shopping-and-gift-20241111

    這次用到的 LORA 模型是:

    巧克力咖啡:https://civitai.com/models/197998/chocolate-coffee-style-lora-15sdxl?modelVersionId=890785

    瓷器:https://civitai.com/models/209773/porcelain-style-fluxsdxl?modelVersionId=908818

    沙:https://civitai.com/models/208699/sand-style-fluxsdxl?modelVersionId=908805

    有了之前風格化的經驗,這回輕車熟路。但在第一輪實驗時發現,場景裡面有大量的人物,出圖特別崩。第二輪正式做的時候,決定完全擯棄人物。效果不錯。本來還想做一隻貓貓在電腦前購物,它頭上有一個巨大的幻象。幻象是張牙舞爪的貓貓靈四處出擊(前段時間巨大動物靈在 reddit 上特別流行)。但考慮到這個項目的商業屬性,當前還是盡量少些個人化整活啦~ 另外,關於購物和禮物主題的文案可以寫蠻多,不過年底還有其他的機會。打算留給之後寫,所以這期的文案就幾乎為零了。圖片也純糖水~

    今天也測試了自動化 markdown 生成,暨自動化圖片重命名工具 https://github.com/sudoghut/bookworm-light-astro/tree/main/generate_data,大大增加了部署的效率。

    週末的時候約一位之前很好的朋友月底看演唱會,得知對方剛剛有了男朋友,要和男朋友去。寂し, 挺難過的。

  • Imghorce is online – Halloween

    Imghorce is online – Halloween

    一直想要邊學圖片生成相關技術一邊發表自己的圖片。可絕大多數圖片站或者不接受 AI 生成的圖片;或者對圖片上傳數量比較大的限制,對於邊學習邊發表記錄歷程的想法就很不友好。於是,自己做一個叭~ 它叫做 Imghorece. 來自 Image 和 Force.

    網站的架構是 Astro, 能容易地部署在 netlify 上. 就像 Astro 的宣言 The web framework for content-driven websites. 部署之後,雖然需要改一些代碼,但完成基本的網頁功能簡化和平面設計之後,接下來確實就可以安心專注內容了。至於圖片站 blog 裡面 md 格式,被我設計得有些複雜,並且設計還在修改中。這個 md 格式手寫起來有點麻煩,但在基本內容板塊設計穩定下來之後,用 python 寫一個 md 生成器就很方便了。

    圖片之前考慮過部署在 GitHub. 仔細考慮之後,還是放在自己在 Hostgator 的網站上,因為 Astro 這類非數據庫類型的平台很少有點擊數量追蹤功能。我還蠻希望在網站的運營過程中知道各圖片受歡迎的程度。而文件被訪問的記錄,透過 Hostgator 很輕鬆地可以知道。

    關於圖片生成,當前選型是 Flux.1 Schunell. 這個模型允許商用,所以網站分享出來之後,無論別人如何使用,還是我自己未來在網站上加廣告條也都少了很多麻煩。另一方面,如果未來如果運營得健康,買 Flux 的會員用 dev 或者 pro 生可商用的圖也是未來可能的方案。許可證選擇了比較寬鬆的:Creative Commons Attribution 4.0 International licence.

    這裡記錄了 Imghorce 圖片站的宗旨:https://imghorce.oopus.info/authors/img-oop/

    第一个 POST 是即將到來 Halloween 相關的圖片: https://imghorce.oopus.info/post-halloween-20241020/

    這裡也分享一張沒有上傳到圖片站上的圖片(這張圖用的模型是 Flux.1 Dev. 對於商用並沒有那麼自由)。它叫做 Greeky. 在 Morton, Lisa. 2012. Trick or Treat : A History of Halloween. London: Reaktion Books 中提到 Halloween 的起源:

    “Samhain was also an important day for administration, akin to the US Tax Day in modern times. A yearly gathering was held at Tara, the ancient seat of kings, where three days’ worth of feasting and sporting alternated with debt repayment and trials (those who were found guilty of particularly severe crimes were executed then as well).” Deepl 翻譯: Samhain 也是一個重要的行政日,類似於現代美國的納稅日。一年一度的聚會在古代國王的所在地塔拉 (Tara) 舉行,三天的宴會和體育活動與還債和審判交替進行(那些被判犯有特別嚴重罪行的人也會在這一天被處決)。

    於是生成的思路是對王權(國王)和財權(商人)之間在 Samhain 節相互博弈的想象。

  • Documents folder in Windows

    In the Windows system, there are likely up to four different types of ‘Documents’ that you can find in your Windows system:

    In your local user account folder:

    x:\Users\{user}\Documents\

    In your OneDrive private user account folder:

    C:\Users\{user}\OneDrive\document

    In your OneDrive organization user account folder:

    C:\Users\sudos\OneDrive – Harvard University\Documents

    In the Documents shortcut (this shortcut links to the first user account folder you logged in):

    Documents

  • A SQL procedure to query a column in all the tables

    The procedure to query

    DELIMITER $$
    CREATE PROCEDURE FindCSourceRecords()
    BEGIN
      DECLARE done INT DEFAULT FALSE;
      DECLARE tableName VARCHAR(255);
      DECLARE cur CURSOR FOR 
        SELECT TABLE_NAME 
        FROM INFORMATION_SCHEMA.COLUMNS 
        WHERE COLUMN_NAME = 'c_source' 
        AND TABLE_SCHEMA = 'cbdb_data'; -- Replace with your database name
      DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
    
      OPEN cur;
    
      read_loop: LOOP
        FETCH cur INTO tableName;
        IF done THEN
          LEAVE read_loop;
        END IF;
    
        -- Corrected dynamic SQL to properly execute and check for existence
        SET @s = CONCAT('SELECT EXISTS (SELECT 1 FROM ', tableName, ' WHERE c_source = 38299) INTO @exists;');
        PREPARE stmt FROM @s;
        EXECUTE stmt;
        DEALLOCATE PREPARE stmt;
    
        -- Check if the query found a row and then do something with the result
        IF @exists THEN
          -- This is a placeholder action; you might want to SELECT the table name or insert it into a log
          SELECT CONCAT('Found in table: ', tableName) AS Result;
        END IF;
    
      END LOOP;
    
      CLOSE cur;
    END$$
    
    DELIMITER ;

    Call query procedure

    CALL FindCSourceRecords();

    Remove query procedure

    DROP PROCEDURE IF EXISTS FindCSourceRecords;

    The procedure to update

    DELIMITER $$
    
    CREATE PROCEDURE UpdateCSourceRecords()
    BEGIN
      DECLARE done INT DEFAULT FALSE;
      DECLARE tableName VARCHAR(255);
      DECLARE cur CURSOR FOR 
        SELECT TABLE_NAME 
        FROM INFORMATION_SCHEMA.COLUMNS 
        WHERE COLUMN_NAME = 'c_source' 
        AND TABLE_SCHEMA = 'cbdb_data'; -- Replace with your actual database name
      DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
    
      OPEN cur;
    
      read_loop: LOOP
        FETCH cur INTO tableName;
        IF done THEN
          LEAVE read_loop;
        END IF;
    
        -- Dynamic SQL for updating c_source values
        SET @s = CONCAT('UPDATE ', tableName, ' SET c_source = 9334 WHERE c_source = 38299;');
        PREPARE stmt FROM @s;
        EXECUTE stmt;
        DEALLOCATE PREPARE stmt;
    
      END LOOP;
    
      CLOSE cur;
    END$$
    
    DELIMITER ;

    Call update procedure

    CALL UpdateCSourceRecords();

    Remove update procedure

    DROP PROCEDURE IF EXISTS UpdateCSourceRecords;
  • Win11 環境下在 MS Access 中複製數據頻繁卡死的解決方案

    某次升級之後,即使從 MS Access 中複製很少量的數據,系統也會卡死。關於這個問題的解決,除了卸載對應的升級包以外,也可以嘗試用 admin 權限啟動 Access,之後再打開所需要的數據庫來複製數據。

    參考:https://techcommunity.microsoft.com/t5/access/access-freezes-when-i-copy-a-record/m-p/3699497/highlight/true#M7066

  • 艾略特荒原的英語語言評分

    I trained a multi-output regression model(training data: https://www.kaggle.com/competitions/feedback-prize-english-language-learning) to grade the first paragraph of T.S. Eliot’s The Waste Land. You can imagine that AI saying: Well, your vocabulary is good(3 out of 5). Syntax and grammar are not bad(2.95 out of 5), but you still need to improve your cohesion, phraseology and conventions.

  • Deep Learning Network

    【 kaggle.com 】的領導人之一是【Jeremy Howard】:

    【Jeremy Howard】 and 【Sylvain Gugger】 合作了一本書叫: Deep Learning for Coders with 【Fastai and PyTorch】: AI Applications Without a PhD https://www.amazon.com/Deep-Learning-Coders-fastai-PyTorch/dp/1492045527:

    【Sylvain Gugger】 在 【huggingface 】的教程中教授了很多 https://huggingface.co/course/chapter1/1?fw=pt :

    這個耶誕、元旦假期的深度神經網路學習完全被這個 social network 支配了~